Merge pull request #5083 from VidVidex/master

Fix downloading attachments with unusual filenames [WIP]
This commit is contained in:
Lauri Ojansivu 2023-08-16 20:30:43 +03:00 committed by GitHub
commit 8a1c2e8860
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -292,13 +292,16 @@ Template.cardAttachmentsPopup.events({
let uploads = [];
for (const file of files) {
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 = {
file: file,
fileId: fileId,
fileName: fileName,
meta: Utils.getCommonAttachmentMetaFrom(card),
chunkSize: 'dynamic',
};