Skip to content

Commit

Permalink
[2.0.0] Saml Helper Image Fix
Browse files Browse the repository at this point in the history
- Fixes parsing of heavy images
- Fixes parsing of data base64 prefix
  • Loading branch information
malulleybovo committed Nov 3, 2021
1 parent ec19a0b commit 89fc98a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/utils/SAMLFileUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = /<overlay-img [^>]*>/.exec(rawFileContent);
rawHelperImageContent = rawHelperImageContent === null ? null : rawHelperImageContent[0];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 89fc98a

Please sign in to comment.