diff --git a/client/commonFramework.js b/client/commonFramework.js
index 4311f7d1ffd..34115509786 100644
--- a/client/commonFramework.js
+++ b/client/commonFramework.js
@@ -37,6 +37,18 @@ var common = (function() {
.replace(/fcces/gi, '');
};
+ common.replaceFormActionAttr = function replaceFormAction(value) {
+ return value.replace(/
/, function(val) {
+ return val.replace('action=', 'fccfaa=');
+ });
+ };
+
+ common.replaceFccfaaAttr = function replaceFccfaaAttr(value) {
+ return value.replace(//, function(val) {
+ return val.replace('fccfaa=', 'action=');
+ });
+ };
+
return common;
})();
@@ -44,6 +56,17 @@ var common = (function() {
common.codeUri = (function(common, encode, decode, location, history) {
var replaceScriptTags = common.replaceScriptTags;
var replaceSafeTags = common.replaceSafeTags;
+ var replaceFormActionAttr = common.replaceFormActionAttr;
+ var replaceFccfaaAttr = common.replaceFccfaaAttr;
+
+ function encodeFcc(val) {
+ return replaceScriptTags(replaceFormActionAttr(val));
+ }
+
+ function decodeFcc(val) {
+ return replaceSafeTags(replaceFccfaaAttr(val));
+ }
+
var codeUri = {
encode: function(code) {
return encode(code);
@@ -72,10 +95,14 @@ common.codeUri = (function(common, encode, decode, location, history) {
}, false);
},
isAlive: function() {
- return codeUri.isInQuery(location.search) ||
+ return codeUri.enabled &&
+ codeUri.isInQuery(location.search) ||
codeUri.isInQuery(location.hash);
},
parse: function() {
+ if (!codeUri.enabled) {
+ return null;
+ }
var query;
if (location.search && codeUri.isInQuery(location.search)) {
query = location.search.replace(/^\?/, '');
@@ -85,7 +112,7 @@ common.codeUri = (function(common, encode, decode, location, history) {
null,
location.href.split('?')[0]
);
- location.hash = '#?' + replaceScriptTags(query);
+ location.hash = '#?' + encodeFcc(query);
}
} else {
query = location.hash.replace(/^\#\?/, '');
@@ -100,17 +127,21 @@ common.codeUri = (function(common, encode, decode, location, history) {
var key = param.split('=')[0];
var value = param.split('=')[1];
if (key === 'solution') {
- return replaceSafeTags(codeUri.decode(value || ''));
+ return decodeFcc(codeUri.decode(value || ''));
}
return solution;
}, null);
},
querify: function(solution) {
+ if (!codeUri.enabled) {
+ return null;
+ }
location.hash = '?solution=' +
- codeUri.encode(replaceScriptTags(solution));
+ codeUri.encode(encodeFcc(solution));
return solution;
- }
+ },
+ enabled: true
};
common.init.push(function() {
@@ -459,6 +490,7 @@ function workerError(error) {
var housing = $('#testSuite');
if (display.html() !== error) {
display.remove();
+
housing.prepend(
'' +
error.replace(/j\$/gi, '$').replace(/jdocument/gi, 'document').replace(/jjQuery/gi, 'jQuery') +
@@ -485,7 +517,10 @@ function safeHTMLRun(test) {
var codeStorage = common.codeStorage;
if (common.challengeType === '0') {
var previewFrame = document.getElementById('preview');
- var preview = previewFrame.contentDocument || previewFrame.contentWindow.document;
+
+ var preview = previewFrame.contentDocument ||
+ previewFrame.contentWindow.document;
+
if (editor.getValue().match(/\