From 370a1f0f02f6a42c77fc137b7762d48f78d8a677 Mon Sep 17 00:00:00 2001 From: kunj-sangani Date: Sat, 10 Apr 2021 16:54:05 +0530 Subject: [PATCH] #801 updated filename replacement logic --- src/services/SPService.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/services/SPService.ts b/src/services/SPService.ts index 7968c784a..ed4a98673 100644 --- a/src/services/SPService.ts +++ b/src/services/SPService.ts @@ -246,7 +246,9 @@ export default class SPService implements ISPService { public async addAttachment(listId: string, itemId: number, fileName: string, file: File, webUrl?: string): Promise { try { // Remove special characters in FileName - fileName = fileName.replace(/[^\.\w\s\&\-]/gi, ''); + //Updating the escape characters for filename as per the doucmentations + //https://support.microsoft.com/en-us/kb/905231 + fileName = fileName.replace(/[\~\#\%\&\*\{\}\\\:\<\>\?\/\+\|]/gi, ''); // Check if attachment exists const fileExists = await this.checkAttachmentExists(listId, itemId, fileName, webUrl); // Delete attachment if it exists