Skip to content

Commit

Permalink
Restore @icon check and modify graceful failure landing page
Browse files Browse the repository at this point in the history
* `statusCode` is a string in the case of *node* failures... change `statusCodePage` code to accommodate this.
* revert suspension again... hopefully the last time

Applies to OpenUserJS#1323 and OpenUserJS#37
  • Loading branch information
Martii committed Feb 10, 2018
1 parent 38a7610 commit cd8ce61
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
12 changes: 3 additions & 9 deletions controllers/scriptStorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -1465,12 +1465,6 @@ exports.storeScript = function (aUser, aMeta, aBuf, aUpdate, aCallback) {
}
} else {
fn = /^http:/.test(icon) ? http : https;

// Workaround for #1323
aInnerCallback(null); // NOTE: Suspend further checks
return;
// /Workaround for #1323

fn.get(URL.parse(icon), function (aRes) {
var chunks = [];
aRes.on('data', function (aChunk) {
Expand Down Expand Up @@ -1509,11 +1503,11 @@ exports.storeScript = function (aUser, aMeta, aBuf, aUpdate, aCallback) {
} else {
aInnerCallback(null);
}
}).on('error', function (aErr) {
}).on('error', function (aErr) { // NOTE: response error trap
aInnerCallback(aErr);
});
}).on('error', function (aErr) {
aInnerCallback(aErr); // WARNING: See #1323
}).on('error', function (aErr) { // NOTE: request error trap
aInnerCallback(aErr);
});
}
} else {
Expand Down
6 changes: 5 additions & 1 deletion libs/templateHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ exports.statusCodePage = function (aReq, aRes, aNext, aOptions) {
pageMetadata(aOptions, [aOptions.statusCode, aOptions.statusMessage], aOptions.statusMessage);

//---
aRes.status(aOptions.statusCode).render('pages/statusCodePage', aOptions);
if (typeof aOptions.statusCode !== 'number') {
aRes.status(400).render('pages/statusCodePage', aOptions);
} else {
aRes.status(aOptions.statusCode).render('pages/statusCodePage', aOptions);
}
};

// Add page metadata, containing title, description and keywords.
Expand Down

0 comments on commit cd8ce61

Please sign in to comment.