From acaf45a0e06202d263865a58e5f923db4d923a66 Mon Sep 17 00:00:00 2001 From: ansuz Date: Tue, 5 Sep 2017 11:38:49 +0200 Subject: [PATCH] drop thumbnails if metadata is too large --- www/file/file-crypto.js | 10 +++++++--- www/file/main.js | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/www/file/file-crypto.js b/www/file/file-crypto.js index f2202c8f8..44952fc87 100644 --- a/www/file/file-crypto.js +++ b/www/file/file-crypto.js @@ -206,10 +206,14 @@ define([ var nonce = createNonce(); // encode metadata - var metaBuffer = Array.prototype.slice - .call(Nacl.util.decodeUTF8(JSON.stringify(metadata))); + var plaintext = Nacl.util.decodeUTF8(JSON.stringify(metadata)); - var plaintext = new Uint8Array(metaBuffer); + // if metadata is too large, drop the thumbnail. + if (plaintext.length > 65535) { + var temp = JSON.parse(JSON.stringify(metadata)); + delete metadata.thumbnail; + plaintext = Nacl.util.decodeUTF8(JSON.stringify(temp)); + } var i = 0; diff --git a/www/file/main.js b/www/file/main.js index 79bd70af8..ec3961196 100644 --- a/www/file/main.js +++ b/www/file/main.js @@ -91,6 +91,8 @@ define([ Title.updateTitle(title || Title.defaultTitle); toolbar.addElement(['pageTitle'], {pageTitle: title}); + console.error(metadata); + var displayFile = function (ev, sizeMb, CB) { var called_back; var cb = function (e) {