From a525eab554ff33105a63659120b350bea02576aa Mon Sep 17 00:00:00 2001 From: Marti Martz Date: Fri, 9 Feb 2018 22:08:26 -0700 Subject: [PATCH] Restore `@icon` check and modify graceful failure landing page (#1328) * `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 #1323 and #37 Auto-merge --- controllers/scriptStorage.js | 12 +++--------- libs/templateHelpers.js | 6 +++++- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/controllers/scriptStorage.js b/controllers/scriptStorage.js index c0d4e041a..9208d1277 100644 --- a/controllers/scriptStorage.js +++ b/controllers/scriptStorage.js @@ -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) { @@ -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 { diff --git a/libs/templateHelpers.js b/libs/templateHelpers.js index 289eb80ca..bdf78790b 100644 --- a/libs/templateHelpers.js +++ b/libs/templateHelpers.js @@ -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.