Skip to content

Node.js based forum software built for the modern web

fix: quote filenames

Barış Soner Uşaklı4fb7f5b38baa
diff --git a/src/controllers/admin/cache.js b/src/controllers/admin/cache.js
index fa1abe81d4..e051e5c1f6 100644
--- a/src/controllers/admin/cache.js
+++ b/src/controllers/admin/cache.js
@@ -20,7 +20,7 @@ cacheController.dump = async function (req, res, next) {
}
const data = JSON.stringify(foundCache.dump(), null, 4);
- res.setHeader('Content-disposition', `attachment; filename= ${req.query.name}-cache.json`);
+ res.setHeader('Content-disposition', `attachment; filename="${req.query.name}-cache.json"`);
res.setHeader('Content-type', 'application/json');
res.write(data, (err) => {
if (err) {
diff --git a/src/routes/index.js b/src/routes/index.js
index 4a12a548ce..c59114825e 100644
--- a/src/routes/index.js
+++ b/src/routes/index.js
@@ -181,7 +181,8 @@ function addCoreRoutes(app, router, middleware, mounts) {
maxAge: app.enabled('cache') ? 5184000000 : 0,
setHeaders: (res, filePath) => {
if (path.extname(filePath).toLowerCase() === '.xml') {
- res.setHeader('Content-Disposition', `attachment; filename=${path.basename(filePath)}`);
+ res.setHeader('X-Content-Type-Options', 'nosniff');
+ res.setHeader('Content-Disposition', `attachment; filename="${path.basename(filePath)}"`);
}
},
};