Skip to content

Node.js based forum software built for the modern web

refactor: compare against lowercase path

Barış Soner Uşaklı1b3826062656
diff --git a/src/middleware/index.js b/src/middleware/index.js
index edaec2cd7b..d3ab15b8ee 100644
--- a/src/middleware/index.js
+++ b/src/middleware/index.js
@@ -210,10 +210,10 @@ middleware.privateUploads = function privateUploads(req, res, next) {
return next();
}
- const uploadPrefix = `${nconf.get('relative_path')}/assets/uploads/files`;
+ const uploadPrefix = `${nconf.get('relative_path')}/assets/uploads/files`.toLowerCase();
let requestPath = req.path;
try {
- requestPath = path.posix.normalize(decodeURIComponent(requestPath));
+ requestPath = path.posix.normalize(decodeURIComponent(requestPath)).toLowerCase();
} catch (err) {
return res.status(403).json('not-allowed');
}
@@ -284,7 +284,7 @@ middleware.buildSkinAsset = helpers.try(async (req, res, next) => {
middleware.addUploadHeaders = helpers.try(function addUploadHeaders(req, res, next) {
// Trim uploaded files' timestamps when downloading + force download if unsafe
- const p = path.posix.normalize(decodeURIComponent(req.path));
+ const p = path.posix.normalize(decodeURIComponent(req.path)).toLowerCase();
let basename = path.basename(p);
const extname = path.extname(p).toLowerCase();
const unsafeExtensions = [