From 28344c19dbe10b5a339a02309bac937ac17731d4 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 7807695b8..e5b8dea83 100644 --- a/src/services/SPService.ts +++ b/src/services/SPService.ts @@ -195,7 +195,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