From 5e1d8292c59f384758ce2ecc5208da8ab4dd281e Mon Sep 17 00:00:00 2001 From: ansuz Date: Mon, 26 Dec 2016 14:23:17 +0100 Subject: [PATCH] guard against trying to parse special fragments --- www/common/cryptpad-common.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 4c7df996b..f78535686 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -168,21 +168,25 @@ define([ }; var getHashFromKeys = common.getHashFromKeys = getEditHashFromKeys; + var specialHashes = common.specialHashes = ['iframe']; var getSecrets = common.getSecrets = function (secretHash) { var secret = {}; + var generate = function () { + secret.keys = Crypto.createEditCryptor(); + secret.key = Crypto.createEditCryptor().editKeyStr; + }; if (/#\?path=/.test(window.location.href)) { var arr = window.location.hash.match(/\?path=(.+)/); common.initialPath = arr[1] || undefined; window.location.hash = ''; } if (!secretHash && !/#/.test(window.location.href)) { - secret.keys = Crypto.createEditCryptor(); - secret.key = Crypto.createEditCryptor().editKeyStr; + generate(); + return secret; } else { var hash = secretHash || window.location.hash.slice(1); - if (hash.length === 0) { - secret.keys = Crypto.createEditCryptor(); - secret.key = Crypto.createEditCryptor().editKeyStr; + if (hash.length === 0 || specialHashes.indexOf(hash) !== -1) { + generate(); return secret; } // old hash system : #{hexChanKey}{cryptKey}