guard against trying to parse special fragments

This commit is contained in:
ansuz 2016-12-26 14:23:17 +01:00
parent 51067430f9
commit 5e1d8292c5
1 changed files with 9 additions and 5 deletions

View File

@ -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}