From 61dead9b4a4b8504743d0e5a754458e3a34c1316 Mon Sep 17 00:00:00 2001
From: Dorian Niemiec
{stack}
Please contact with developer/administrator at {contact}.", 501: "The request requires use of a function, which isn't currently implemented by the server.", 502: "The server had an error, while it was acting as a gateway.
Please contact with developer/administrator at {contact}.", - 503: "The service provided by the server is currently unavailable, possibly due of maintenance downtime or capacity problems. Please try again later.
Please contact with developer/administrator at {contact}.", + 503: "The service provided by the server is currently unavailable, possibly due to maintenance downtime or capacity problems. Please try again later.
Please contact with developer/administrator at {contact}.", 504: "The server couldn't get response in time, while it was acting as a gateway.
Please contact with developer/administrator at {contact}.", 505: "The server doesn't support HTTP version used in the request.", 506: "Variant header is configured to be engaged in content negotiation.
Please contact with developer/administrator at {contact}.", @@ -3732,10 +3732,10 @@ if (!cluster.isPrimary) { : (fs.existsSync("." + decodeURIComponent(href) + "/FOOT.html".replace(/\/+/g, "/")) && (os.platform != "win32" || href != "/")) ? fs.readFileSync("." + decodeURIComponent(href) + "/FOOT.html".replace(/\/+/g, "/")).toString() : ""; - + // Check if custom header has HTML tag var headerHasHTMLTag = customDirListingHeader.replace(/|$)/gs, "").match(/])*(?:>|$)/si); - + // Generate HTML head and footer based on configuration and custom content var htmlHead = (!configJSON.enableDirectoryListingWithDefaultHead || head == "" ? (!headerHasHTMLTag @@ -3815,8 +3815,7 @@ if (!cluster.isPrimary) { getStatsForAllFiles(list, "." + decodeURIComponent(href), function (filelist) { // Function to check file extension function checkEXT(filename, ext) { - if (filename.length < ext.length) return false; - return filename.toLowerCase().indexOf(ext) === filename.length - ext.length; + return filename.match(new RegExp("\\." + ext.replace(/([.+*?^$()\[\]{}|\\])/,"\\$1") + "$","i")); } var directoryListingRows = []; @@ -3947,12 +3946,12 @@ if (!cluster.isPrimary) { callServerError(403); serverconsole.errmessage("Directory listing is disabled."); } - + } else { var acceptEncoding = req.headers["accept-encoding"]; if (!acceptEncoding) acceptEncoding = ""; - + // Check if the requested file exists and handle errors fs.stat(readFrom, function (err, stats) { if (err) { @@ -3988,7 +3987,7 @@ if (!cluster.isPrimary) { } var filelen = stats.size; - + //ETag code var fileETag = undefined; if (configJSON.enableETag == undefined || configJSON.enableETag) { @@ -4012,7 +4011,7 @@ if (!cluster.isPrimary) { return; } } - + // Helper function to check if compression is allowed for the file function canCompress(path, list) { var canCompress = true; @@ -4070,7 +4069,7 @@ if (!cluster.isPrimary) { rhd["Content-Length"] = end - begin + 1; if (!(mime.contentType(ext) == false) && ext != "") rhd["Content-Type"] = mime.contentType(ext); if(fileETag) rhd["ETag"] = fileETag; - + if (req.method != "HEAD") { var readStream = fs.createReadStream(readFrom, { start: begin, @@ -4256,7 +4255,7 @@ if (!cluster.isPrimary) { redirect(sanitizedURL, false); return; } - + //URL REWRITING function rewriteURL(address, map) { var rewrittenAddress = address; @@ -4321,7 +4320,7 @@ if (!cluster.isPrimary) { } } } - + //Set response headers if (!isProxy) { var hkh = getCustomHeaders(); @@ -4334,7 +4333,7 @@ if (!cluster.isPrimary) { } } } - + //Check if path is forbidden if ((isForbiddenPath(decodedHref, "config") || isForbiddenPath(decodedHref, "certificates")) && !isProxy) { callServerError(403); @@ -4421,7 +4420,7 @@ if (!cluster.isPrimary) { return; } } - + // Handle HTTP authentication if (authIndex > -1) { var authcode = nonStandardCodes[authIndex]; @@ -5118,7 +5117,7 @@ function start(init) { rla.prompt(); }); } - + if (cluster.isPrimary || cluster.isPrimary === undefined) { //Cluster forking code if (cluster.isPrimary !== undefined && init) { @@ -5187,7 +5186,7 @@ function start(init) { if (msg == "\x12CRASH") process.exit(1); if (msg == "\x12EADDRINUSE" || msg == "\x12EADDRNOTAVAIL" || msg == "\x12EACCES") process.exit(errors[msg.substr(1)]); }); - + // Hangup check and restart setInterval(function () { if (!closedMaster && !exiting) { @@ -5272,7 +5271,7 @@ function start(init) { } } }, 4550); - + // Termination of unused good workers if(cluster.isPrimary !== undefined) { setTimeout(function () {