diff --git a/index.js b/index.js index 85e900c..ee0fcee 100644 --- a/index.js +++ b/index.js @@ -317,8 +317,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } nEnv["SERVER_NAME"] = req.headers.host; nEnv["DOCUMENT_ROOT"] = process.cwd(); - nEnv["PATH_INFO"] = decodeURI(b); - nEnv["PATH_TRANSLATED"] = b ? decodeURI((process.cwd() + (require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : ""; + nEnv["PATH_INFO"] = decodeURIComponent(b); + nEnv["PATH_TRANSLATED"] = b ? ((process.cwd() + decodeURIComponent(require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : ""; nEnv["REQUEST_METHOD"] = req.method; nEnv["GATEWAY_INTERFACE"] = "CGI/1.1"; nEnv["REQUEST_URI"] = (!origHref || origHref == href) ? req.url : (origHref + (uobject.search ? ("?" + uobject.search) : "")); @@ -371,15 +371,15 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e callServerError(403, "RedBrick/" + version); } } else { - fs.stat("." + href, function (err, stats) { + fs.stat("." + decodeURIComponent(href), function (err, stats) { if (!err) { if (!stats.isFile()) { if (isCgiBin || scriptExts.indexOf(".php") != -1) { - fs.stat("." + href + "/index.php", function (e2, s2) { + fs.stat("." + decodeURIComponent(href) + "/index.php", function (e2, s2) { if (!e2 && s2.isFile()) { try { executeCGIWithEnv( - (href + "/index.php").replace(/\/+/g, "/"), + (decodeURIComponent(href) + "/index.php").replace(/\/+/g, "/"), "", req, res, @@ -426,11 +426,11 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } } } else if (isCgiBin || scriptExts.indexOf(".cgi") != -1) { - fs.stat("." + href + "/index.cgi", function (e3, s3) { + fs.stat("." + decodeURIComponent(href) + "/index.cgi", function (e3, s3) { if (!e3 && s3.isFile()) { try { executeCGIWithEnv( - (href + "/index.cgi").replace(/\/+/g, "/"), + (decodeURIComponent(href) + "/index.cgi").replace(/\/+/g, "/"), "", req, res, @@ -485,11 +485,11 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } }); } else if (scriptExts.indexOf(".cgi") != -1) { - fs.stat("." + href + "/index.cgi", function (e3, s3) { + fs.stat("." + decodeURIComponent(href) + "/index.cgi", function (e3, s3) { if (!e3 && s3.isFile()) { try { executeCGIWithEnv( - (href + "/index.cgi").replace(/\/+/g, "/"), + (decodeURIComponent(href) + "/index.cgi").replace(/\/+/g, "/"), "", req, res, @@ -546,7 +546,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e if (isCgiBin || isScriptExt) { try { executeCGIWithEnv( - href, + decodeURIComponent(href), "", req, res, @@ -619,7 +619,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e } }); } - checkPath("." + href, function (pathp) { + checkPath("." + decodeURIComponent(href), function (pathp) { if (!pathp) { elseCallback(); } else {