From 5a5b02b82b9abe3db45ae7ded35fe4df9adaa798 Mon Sep 17 00:00:00 2001 From: yflory Date: Fri, 5 May 2017 11:55:19 +0200 Subject: [PATCH] Don't store in the drive pads without a hash --- www/common/cryptpad-common.js | 10 +++++++--- www/common/userObject.js | 5 +++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 104b67a9b..8096e3044 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -299,10 +299,14 @@ define([ pads.forEach(function (pad, i) { if (pad && typeof(pad) === 'object') { var hash = checkObjectData(pad); - if (!hash || !common.parseHash(hash)) { return; } + if (!hash || !common.parseHash(hash)) { + console.error("[Cryptpad.checkRecentPads] pad had unexpected value", pad); + getStore().removeData(i); + return; + } return pad; } - console.error("[Cryptpad.migrateRecentPads] pad had unexpected value"); + console.error("[Cryptpad.checkRecentPads] pad had unexpected value", pad); getStore().removeData(i); }); }; @@ -571,7 +575,7 @@ define([ return pad; }); - if (!contains) { + if (!contains && href) { var data = makePad(href, name); getStore().pushData(data, function (e) { if (e) { diff --git a/www/common/userObject.js b/www/common/userObject.js index aa61c8573..a7c21f3f3 100644 --- a/www/common/userObject.js +++ b/www/common/userObject.js @@ -883,6 +883,11 @@ define([ toClean.push(el); return; } + if (!el.href) { + debug("Rmoving an element in filesData with a missing href.", el); + toClean.push(el); + return; + } if (rootFiles.indexOf(el.href) === -1) { debug("An element in filesData was not in ROOT, TEMPLATE or TRASH.", el); var name = el.title || NEW_FILE_NAME;