diff --git a/index.js b/index.js index b765830..6757e55 100644 --- a/index.js +++ b/index.js @@ -15,6 +15,19 @@ try { } var configJSONS = JSON.parse(fs.readFileSync(__dirname + "/../../../config.json")); // Read configuration JSON +var exttointerpreteruser = {}; +var scriptExts = []; +try { + exttointerpreteruser = JSON.parse(fs.readFileSync(__dirname + "/../../../redbrick-interpreters.json")); +} catch(ex) { + +} +try { + scriptExts = JSON.parse(fs.readFileSync(__dirname + "/../../../redbrick-scriptexts.json")); +} catch(ex) { + +} + function Mod() {} Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, ext, uobject, search, defaultpage, users, page404, head, foot, fd, elseCallback, configJSON, callServerError, getCustomHeaders, origHref, redirect, parsePostData) { @@ -64,13 +77,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e exttointerpreter[".bat"] = ["cmd", "/c"]; exttointerpreter[".vbs"] = ["cscript"]; } - var exttointerpreteruser = {}; - fs.readFile(__dirname + "/../../../redbrick-interpreters.json", function (err, data) { - if (!err) { - try { - exttointerpreteruser = JSON.parse(data.toString()); - } catch (ex) {} - } + fs.stat(fname, function (err, stats) { if (err) { if (!callServerError) { @@ -269,7 +276,6 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e }); } } - }); } function executeCGIWithEnv(a, b, req, res, pubip, port, software, dh) { @@ -329,6 +335,7 @@ 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" : ""))) { fs.stat("." + href, function (err, stats) { if (!err) { @@ -608,7 +615,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } } }); - } else if ((href == "/redbrick-interpreters.json" || (os.platform() == "win32" && href.toLowerCase() == "/redbrick-interpreters.json")) && path.normalize(__dirname + "/../../..") == process.cwd()) { + } 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()) { if (!callServerError) { res.writeHead(200, "OK", { "Content-Type": "application/json",