diff --git a/index.js b/index.js index 7a59332..c06d825 100644 --- a/index.js +++ b/index.js @@ -336,7 +336,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } var isCgiBin = href.match(new RegExp("/cgi-bin(?:$|[?#/])", os.platform() == "win32" ? "i" : "")); - var isScriptExt = scriptExts.indexOf(ext) != -1; + var isScriptExt = scriptExts.indexOf("." + ext) != -1; 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) { @@ -588,7 +588,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e function checkPath(pth, cb, a) { // Function to check the path of the file and execute CGI script var cpth = pth.split("/"); - if (cpth.length < 3) { + if (cpth.length < (isCgiBin ? 3 : 2)) { cb(false); return; } @@ -602,26 +602,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e rpth: (a !== undefined ? "/" + a : "") }) } else { - fs.stat(pth + "/index.php", function (e2, s2) { - if (!e2 && s2.isFile()) { - cb({ - fpth: (pth + "/index.php").replace(/\/+/g, "/"), - rpth: (a !== undefined ? "/" + a : "") - }) - } else { - fs.stat(pth + "/index.cgi", function (e3, s3) { - if (!e3 && s3.isFile()) { - cb({ - fpth: (pth + "/index.cgi").replace(/\/+/g, "/"), - rpth: (a !== undefined ? "/" + a : "") - }) - } else { - b.unshift(cpth.pop()); - return checkPath(cpth.join("/"), cb, b.join("/")); - } - }); - } - }); + b.unshift(cpth.pop()); + return checkPath(cpth.join("/"), cb, b.join("/")); } }); } @@ -629,6 +611,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e if (!pathp) { elseCallback(); } else { + var newext = path.extname(pathp.fpth); + if(isCgiBin || scriptExts.indexOf(newext) != -1) { try { executeCGIWithEnv( pathp.fpth.substr(1), @@ -676,6 +660,9 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e callServerError(500, "RedBrick/" + version, ex); } } + } else { + elseCallback(); + } } }); } else if (err && err.code == "ENOENT") {