Make code-uri more robust

pull/5035/head
Berkeley Martinez 2015-12-05 14:53:33 -08:00
parent addcd4fa20
commit 415a39ea17
1 changed files with 8 additions and 5 deletions

View File

@ -15,6 +15,7 @@ window.common = (function(global) {
replaceFccfaaAttr replaceFccfaaAttr
} = common; } = common;
const queryRegex = /^(\?|#\?)/;
function encodeFcc(val) { function encodeFcc(val) {
return replaceScriptTags(replaceFormActionAttr(val)); return replaceScriptTags(replaceFormActionAttr(val));
} }
@ -40,9 +41,7 @@ window.common = (function(global) {
return false; return false;
} }
return decoded return decoded
.split('?') .replace(queryRegex, '')
.splice(1)
.pop()
.split('&') .split('&')
.reduce(function(found, param) { .reduce(function(found, param) {
var key = param.split('=')[0]; var key = param.split('=')[0];
@ -62,7 +61,11 @@ window.common = (function(global) {
.split('&') .split('&')
.reduce(function(oldValue, param) { .reduce(function(oldValue, param) {
var key = param.split('=')[0]; var key = param.split('=')[0];
var value = param.split('=')[1]; var value = param
.split('=')
.slice(1)
.join('=');
if (key === keyToFind) { if (key === keyToFind) {
return value; return value;
} }
@ -127,7 +130,7 @@ window.common = (function(global) {
enabled: true, enabled: true,
shouldRun() { shouldRun() {
return !this.getKeyInQuery( return !this.getKeyInQuery(
(location.search || location.hash).replace(/^(\?|#\?)/, ''), (location.search || location.hash).replace(queryRegex, ''),
'run' 'run'
); );
} }