Changed redbrick-interpreters handling and added stub support for redbrick-scriptexts.json

This commit is contained in:
Dorian Niemiec 2023-11-23 03:37:18 +01:00
parent 598073594e
commit f19b2e2f75

View file

@ -15,6 +15,19 @@ try {
} }
var configJSONS = JSON.parse(fs.readFileSync(__dirname + "/../../../config.json")); // Read configuration JSON 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() {} 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) { 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[".bat"] = ["cmd", "/c"];
exttointerpreter[".vbs"] = ["cscript"]; 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) { fs.stat(fname, function (err, stats) {
if (err) { if (err) {
if (!callServerError) { 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) { 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); executeCGI("." + a, req, res, dh, nEnv);
} }
if (href.match(new RegExp("/cgi-bin(?:$|[?#/])", os.platform() == "win32" ? "i" : ""))) { if (href.match(new RegExp("/cgi-bin(?:$|[?#/])", os.platform() == "win32" ? "i" : ""))) {
fs.stat("." + href, function (err, stats) { fs.stat("." + href, function (err, stats) {
if (!err) { 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) { if (!callServerError) {
res.writeHead(200, "OK", { res.writeHead(200, "OK", {
"Content-Type": "application/json", "Content-Type": "application/json",