Просмотр исходного кода

Merge pull request #8043 from weseek/imprv/129221-correspond-prohibited-characters

imprv: Correspond prohibited characters
Ryoji Shimizu 2 лет назад
Родитель
Сommit
53f8f94086
1 измененных файлов с 4 добавлено и 2 удалено
  1. 4 2
      apps/app/src/server/routes/apiv3/page.js

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

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