From 08c006e68236dc386da13962eca2922aaac3b96b Mon Sep 17 00:00:00 2001 From: ClemDee Date: Fri, 2 Aug 2019 12:21:37 +0200 Subject: [PATCH] Use Nacl to decode base64 thumbnail data --- www/common/common-thumbnail.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/www/common/common-thumbnail.js b/www/common/common-thumbnail.js index 4dfab1457..62771223a 100644 --- a/www/common/common-thumbnail.js +++ b/www/common/common-thumbnail.js @@ -230,20 +230,15 @@ define([ if (!Visible.currently()) { to = window.setTimeout(interval, Thumb.UPDATE_FIRST); } }; - var stringToBlobToUrl = function (b64) { - var byteString = atob(b64.split(',')[1]); - var ab = new ArrayBuffer(byteString.length); - var ia = new Uint8Array(ab); - for (var i = 0; i < byteString.length; i++) { - ia[i] = byteString.charCodeAt(i); - } - var blob = new Blob([ab], {type: "image/png"}); - var url = URL.createObjectURL(blob); - return url; - }; + var addThumbnail = function (err, thumb, $span, cb) { + var u8 = Nacl.util.decodeBase64(thumb.split(',')[1]); + var blob = new Blob([u8], { + type: 'image/png' + }); + var url = URL.createObjectURL(blob); var img = new Image(); - img.src = stringToBlobToUrl(thumb); + img.src = url; $span.find('.cp-icon').hide(); $span.prepend(img); cb($(img));