From 89fc98a9191f53b13cd7cafc52d64a8b4a925dcd Mon Sep 17 00:00:00 2001 From: malulleybovo Date: Wed, 3 Nov 2021 01:14:33 -0500 Subject: [PATCH] [2.0.0] Saml Helper Image Fix - Fixes parsing of heavy images - Fixes parsing of data base64 prefix --- src/utils/SAMLFileUtils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/utils/SAMLFileUtils.js b/src/utils/SAMLFileUtils.js index ac71803..083726e 100644 --- a/src/utils/SAMLFileUtils.js +++ b/src/utils/SAMLFileUtils.js @@ -33,7 +33,7 @@ class SAMLFileUtils { static async parseIntoSymbolArt({ fileDataArrayBuffer }) { try { - let rawFileContent = String.fromCharCode.apply(String, new Uint8Array(fileDataArrayBuffer)); + let rawFileContent = (new Uint8Array(fileDataArrayBuffer)).reduce((a, b) => a + String.fromCharCode(b), ''); rawFileContent = rawFileContent.replace(/[\u0080-\uffff]/g, ''); let rawHelperImageContent = /]*>/.exec(rawFileContent); rawHelperImageContent = rawHelperImageContent === null ? null : rawHelperImageContent[0]; @@ -153,7 +153,7 @@ class SAMLFileUtils { } } try { - let utf8 = atob(rawSource); + let utf8 = atob(rawSource.replace(/^data:.*;base64,/, '')); if (!(/[^\x00-\x7f]/.test(utf8))) throw new Error(); await symbolArt.helperImage.setImage({ fromBase64EncodedString: rawSource }); symbolArt.helperImage.positionX = positionX;