浏览代码

Merge pull request #5083 from VidVidex/master

Fix downloading attachments with unusual filenames [WIP]
Lauri Ojansivu 1 年之前
父节点
当前提交
8a1c2e8860
共有 1 个文件被更改,包括 6 次插入3 次删除
  1. 6 3
      client/components/cards/attachments.js

+ 6 - 3
client/components/cards/attachments.js

@@ -292,13 +292,16 @@ Template.cardAttachmentsPopup.events({
       let uploads = [];
       let uploads = [];
       for (const file of files) {
       for (const file of files) {
         const fileId = new ObjectID().toString();
         const fileId = new ObjectID().toString();
-        // If filename is not same as sanitized filename, has XSS, then cancel upload
-        if (file.name !== DOMPurify.sanitize(file.name)) {
-          return false;
+        const fileName = DOMPurify.sanitize(file.name);
+
+        if (fileName !== file.name) {
+          console.warn('Detected possible XSS in file: ', file.name + '. Renamed to: ', fileName + '.');
         }
         }
+
         const config = {
         const config = {
           file: file,
           file: file,
           fileId: fileId,
           fileId: fileId,
+          fileName: fileName,
           meta: Utils.getCommonAttachmentMetaFrom(card),
           meta: Utils.getCommonAttachmentMetaFrom(card),
           chunkSize: 'dynamic',
           chunkSize: 'dynamic',
         };
         };