Fixed bug with URL containing URL-encoded characters

This commit is contained in:
Dorian Niemiec 2024-01-29 19:03:20 +00:00
parent 98194e6f47
commit 45139795f5

View file

@ -151,8 +151,8 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
headers: req.headers, headers: req.headers,
input: inputStream, input: inputStream,
scriptName: a, scriptName: a,
pathInfo: decodeURI(b), pathInfo: decodeURIComponent(b),
pathTranslated: b ? decodeURI((process.cwd() + (require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : "", pathTranslated: b ? ((process.cwd() + decodeURIComponent(require("os").platform == "win32" ? b.replace(/\//g, "\\") : b)).replace((require("os").platform == "win32" ? /\\\\/g : /\/\//g), (require("os").platform == "win32" ? "\\" : "/"))) : "",
scheme: req.socket.encrypted ? "https" : "http", scheme: req.socket.encrypted ? "https" : "http",
env: {}, env: {},
jsgi: { jsgi: {
@ -200,14 +200,14 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
} }
if (href.match(new RegExp("/jsgi-bin(?:$|[?#/])",os.platform() == "win32" ? "i" : ""))) { if (href.match(new RegExp("/jsgi-bin(?:$|[?#/])",os.platform() == "win32" ? "i" : ""))) {
fs.stat("." + href, function (err, stats) { fs.stat("." + decodeURIComponent(href), function (err, stats) {
if (!err) { if (!err) {
if (!stats.isFile()) { if (!stats.isFile()) {
elseCallback(); elseCallback();
} else { } else {
try { try {
executeJSGIWithReqObj( executeJSGIWithReqObj(
href, decodeURIComponent(href),
"", "",
req, req,
res, res,
@ -276,7 +276,7 @@ Mod.prototype.callback = function (req, res, serverconsole, responseEnd, href, e
} }
}); });
} }
checkPath("." + href, function (pathp) { checkPath("." + decodeURIComponent(href), function (pathp) {
if (!pathp) { if (!pathp) {
elseCallback(); elseCallback();
} else { } else {