|
@@ -6,6 +6,7 @@ import fs from 'fs';
|
|
import path from 'path';
|
|
import path from 'path';
|
|
import { AttachmentStoreStrategyFilesystem, AttachmentStoreStrategyGridFs, AttachmentStoreStrategyS3 } from '/models/lib/attachmentStoreStrategy';
|
|
import { AttachmentStoreStrategyFilesystem, AttachmentStoreStrategyGridFs, AttachmentStoreStrategyS3 } from '/models/lib/attachmentStoreStrategy';
|
|
import FileStoreStrategyFactory, {moveToStorage, rename, STORAGE_NAME_FILESYSTEM, STORAGE_NAME_GRIDFS, STORAGE_NAME_S3} from '/models/lib/fileStoreStrategy';
|
|
import FileStoreStrategyFactory, {moveToStorage, rename, STORAGE_NAME_FILESYSTEM, STORAGE_NAME_GRIDFS, STORAGE_NAME_S3} from '/models/lib/fileStoreStrategy';
|
|
|
|
+import DOMPurify from 'isomorphic-dompurify';
|
|
|
|
|
|
let attachmentUploadExternalProgram;
|
|
let attachmentUploadExternalProgram;
|
|
let attachmentUploadMimeTypes = [];
|
|
let attachmentUploadMimeTypes = [];
|
|
@@ -149,9 +150,11 @@ if (Meteor.isServer) {
|
|
renameAttachment(fileObjId, newName) {
|
|
renameAttachment(fileObjId, newName) {
|
|
check(fileObjId, String);
|
|
check(fileObjId, String);
|
|
check(newName, String);
|
|
check(newName, String);
|
|
-
|
|
|
|
- const fileObj = Attachments.findOne({_id: fileObjId});
|
|
|
|
- rename(fileObj, newName, fileStoreStrategyFactory);
|
|
|
|
|
|
+ // If new name is same as sanitized name, does not have XSS, allow rename file
|
|
|
|
+ if (newName === DOMPurify.sanitize(newName)) {
|
|
|
|
+ const fileObj = Attachments.findOne({_id: fileObjId});
|
|
|
|
+ rename(fileObj, newName, fileStoreStrategyFactory);
|
|
|
|
+ }
|
|
},
|
|
},
|
|
validateAttachment(fileObjId) {
|
|
validateAttachment(fileObjId) {
|
|
check(fileObjId, String);
|
|
check(fileObjId, String);
|