diff --git a/common/utils/encode-decode.js b/common/utils/encode-decode.js index 27fe4faa5a..b63641da7a 100644 --- a/common/utils/encode-decode.js +++ b/common/utils/encode-decode.js @@ -1,46 +1,38 @@ -import flow from 'lodash/flow'; +import _ from 'lodash/fp'; // we don't store loop protect disable key -export function removeNoprotect(val) { - return val.replace(/noprotect/gi, ''); -} +export const removeNoprotect = _.replace(/noprotect/gi, ''); -export function encodeScriptTags(val) { - return val - .replace(/'); -} +export const decodeScriptTags = _.flow( + _.replace(/fccss/gi, '') +); -export function encodeFormAction(val) { - return val.replace( - // look for attributes in a form - /
+`; +const formEncoded = ` + +`; + +test('encodeFormAction', t => { + t.plan(1); + t.equal( + encodeFormAction(formDecoded), + formEncoded + ); +}); + +test('decodeFormAction', t => { + t.plan(1); + t.equal( + decodeFormAction(formEncoded), + formDecoded + ); +}); + +test('encodeFcc', t => { + t.plan(1); + t.equal( + encodeFcc('//noprotect' + scriptDecoded + formDecoded), + '//' + scriptEncoded + formEncoded + ); +}); + +test('decodeFcc', t => { + t.plan(1); + t.equal( + decodeFcc(scriptEncoded + formEncoded), + scriptDecoded + formDecoded + ); +});