Explorar o código

129221 use replace to escape

soumaeda %!s(int64=2) %!d(string=hai) anos
pai
achega
12987f8313
Modificáronse 1 ficheiros con 2 adicións e 1 borrados
  1. 2 1
      apps/app/src/server/routes/apiv3/page.js

+ 2 - 1
apps/app/src/server/routes/apiv3/page.js

@@ -618,6 +618,7 @@ module.exports = (crowi) => {
     }
 
     const fileName = path.basename(pagePath);
+    const sanitizedFileName = fileName.replace(/[\\/:;"*?<>,-」ˆ|]/g, '_');
     let stream;
 
     try {
@@ -629,7 +630,7 @@ module.exports = (crowi) => {
     }
 
     res.set({
-      'Content-Disposition': `attachment;filename*=UTF-8''${fileName}.${format}`,
+      'Content-Disposition': `attachment;filename*=UTF-8''${encodeURIComponent(sanitizedFileName)}.${format}`,
     });
 
     const parameters = {