From cae1d77e4f3007a45aeecaa2fd469f3b5680d944 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Thu, 23 Nov 2023 03:44:25 +0100 Subject: [PATCH] Replaced error handler --- index.js | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 6757e55..70a5b37 100644 --- a/index.js +++ b/index.js @@ -335,8 +335,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e executeCGI("." + a, req, res, dh, nEnv); } - - if (href.match(new RegExp("/cgi-bin(?:$|[?#/])", os.platform() == "win32" ? "i" : ""))) { + var isCgiBin = href.match(new RegExp("/cgi-bin(?:$|[?#/])", os.platform() == "win32" ? "i" : "")); + if (isCgiBin) { fs.stat("." + href, function (err, stats) { if (!err) { if (!stats.isFile()) { @@ -590,29 +590,6 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e }); } else if (err && err.code == "ENOENT") { elseCallback(); //Invoke default error handler - } else { - if (!callServerError) { - res.writeHead(500, "Internal Server Error", abheaders); - res.write( - "500 Internal Server Error

500 Internal Server Error

A server had unexpected exception. Below, the stack trace of the error is shown:

" + - err.stack.replace(/\r\n/g, "
").replace(/\n/g, "
").replace(/\r/g, "
").replace(/ /g, " ") + - "

Please contact the developer/administrator of the website.

SVR.JS " + - configJSON.version + - " (" + - os.platform()[0].toUpperCase() + - os.platform().slice(1) + - "; Node.JS/" + - process.version + - ") RedBrick/" + - version + - " " + - (req.headers.host == undefined ? "" : " on " + req.headers.host) + - "

" - ); - res.end(); - } else { - callServerError(500, "RedBrick/" + version, err); - } } }); } else if ((href == "/redbrick-interpreters.json" || href == "/redbrick-scriptexts.json" || (os.platform() == "win32" && (href.toLowerCase() == "/redbrick-interpreters.json" || href.toLowerCase() == "/redbrick-scriptexts.json"))) && path.normalize(__dirname + "/../../..") == process.cwd()) {