From b2e2eaa594697f19d308c93123986e48e475c0e5 Mon Sep 17 00:00:00 2001 From: Stuart Date: Tue, 14 Jun 2016 00:25:42 +0100 Subject: [PATCH] Fix/Loop Protect - Remove noprotect from saved code --- client/commonFramework/code-storage.js | 6 +++++- client/commonFramework/code-uri.js | 5 +++-- client/commonFramework/init.js | 4 ++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/client/commonFramework/code-storage.js b/client/commonFramework/code-storage.js index e7ff937528..4eca143dad 100644 --- a/client/commonFramework/code-storage.js +++ b/client/commonFramework/code-storage.js @@ -5,6 +5,10 @@ window.common = (function(global) { common = { init: [] } } = global; + const { + replaceNoprotect + } = common; + var challengePrefix = [ 'Bonfire: ', 'Waypoint: ', @@ -54,7 +58,7 @@ window.common = (function(global) { console.log('unable to save to storage'); return code; } - localStorage.setItem(key + 'Val', code); + localStorage.setItem(key + 'Val', replaceNoprotect(code)); return code; } }; diff --git a/client/commonFramework/code-uri.js b/client/commonFramework/code-uri.js index fefe45e0fe..c2642aa264 100644 --- a/client/commonFramework/code-uri.js +++ b/client/commonFramework/code-uri.js @@ -12,12 +12,13 @@ window.common = (function(global) { replaceScriptTags, replaceSafeTags, replaceFormActionAttr, - replaceFccfaaAttr + replaceFccfaaAttr, + replaceNoprotect } = common; const queryRegex = /^(\?|#\?)/; function encodeFcc(val) { - return replaceScriptTags(replaceFormActionAttr(val)); + return replaceScriptTags(replaceFormActionAttr(replaceNoprotect(val))); } function decodeFcc(val) { diff --git a/client/commonFramework/init.js b/client/commonFramework/init.js index e054bab6c1..7344e6f0be 100644 --- a/client/commonFramework/init.js +++ b/client/commonFramework/init.js @@ -33,6 +33,10 @@ window.common = (function(global) { common.seed = common.arrayToNewLineString(common.challengeSeed); + common.replaceNoprotect = function replaceNoprotect(value) { + return value.replace(/noprotect/gi, ''); + }; + common.replaceScriptTags = function replaceScriptTags(value) { return value .replace(/