Skip to content

Commit

Permalink
Fix for no @name scripts
Browse files Browse the repository at this point in the history
* Crashes the server when removing or never existing `@name` but localized ones exist
* Not entirely sure why one needs to `encodedURI` and the other `decodeURI` but redirect has issue ... possibly a current *node* issue
* Change text to import since it's not uploading a script technically

Additionally applies to OpenUserJS#200, OpenUserJS#226 edge case, and a bit from OpenUserJS#655 detection
  • Loading branch information
Martii committed Jul 22, 2015
1 parent 2384f5c commit 126c6c1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ exports.storeScript = function (aUser, aMeta, aBuf, aCallback, aUpdate) {
if (!aMeta) { return aCallback(null); }

if (!isLibrary) {
scriptName = cleanFilename(aMeta.name, '');
scriptName = (typeof aMeta.name === 'string' ? cleanFilename(aMeta.name, '') : null);

// Can't install a script without a @name (maybe replace with random value)
if (!scriptName) { return aCallback(null); }
Expand Down
4 changes: 2 additions & 2 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ exports.userGitHubImportScriptPage = function (aReq, aRes, aNext) {
options.script = aScript;
aCallback(null);
} else {
aCallback('Error while uploading script.');
aCallback('Error while importing script.');
}
};

Expand Down Expand Up @@ -1137,7 +1137,7 @@ exports.submitSource = function (aReq, aRes, aNext) {
scriptStorage.storeScript(aUser, aMeta, aSource, function (aScript) {
var redirectUrl = encodeURI(aScript ? (aScript.isLib ? '/libs/'
+ aScript.installName.replace(jsRegex, '') : '/scripts/'
+ aScript.installName.replace(userjsRegex, '')) : aReq.body.url);
+ aScript.installName.replace(userjsRegex, '')) : decodeURI(aReq.body.url));

if (!aScript || !aReq.body.original) {
return aRes.redirect(redirectUrl);
Expand Down

0 comments on commit 126c6c1

Please sign in to comment.