Try to fix build errors on some platforms.

Thanks to xet7 !

Related #4842
This commit is contained in:
Lauri Ojansivu 2023-02-21 21:27:34 +02:00
parent f1092c6f40
commit fd9478dc57
5 changed files with 12 additions and 468 deletions

View file

@ -6,7 +6,6 @@ import fs from 'fs';
import path from 'path';
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 DOMPurify from 'isomorphic-dompurify';
let attachmentUploadExternalProgram;
let attachmentUploadMimeTypes = [];
@ -150,12 +149,9 @@ if (Meteor.isServer) {
renameAttachment(fileObjId, newName) {
check(fileObjId, String);
check(newName, String);
// If new name is same as sanitized name, does not have XSS, allow rename file
// Using isomorphic-dompurify that is isometric so it works also serverside.
if (newName === DOMPurify.sanitize(newName)) {
const fileObj = Attachments.findOne({_id: fileObjId});
rename(fileObj, newName, fileStoreStrategyFactory);
}
const fileObj = Attachments.findOne({_id: fileObjId});
rename(fileObj, newName, fileStoreStrategyFactory);
},
validateAttachment(fileObjId) {
check(fileObjId, String);