Skip to content
Snippets Groups Projects
Commit 9d01a8d4 authored by lehtint6's avatar lehtint6
Browse files

Escape editor code in feedback

parent e9070f16
No related branches found
No related tags found
No related merge requests found
......@@ -79,9 +79,19 @@ ACOSWebdev.prototype.extendGrade = function (eventOrMutations, cb) {
ACOSWebdev.prototype.extendProtocolFeedback = function (feedback) {
var $out = $(this.$editorOutput.find('iframe').get(0).contentWindow.document.body);
$out.find('script').remove();
return '<pre><code>' + this.editor.getValue() + '</code></pre><div>' + $out.html() + '</div>';
return '<pre><code>' + this.esc(this.editor.getValue()) + '</code></pre><div>' + $out.html() + '</div>';
};
ACOSWebdev.prototype.esc = function (str) {
if (str) {
var rep = {'&': '&amp;', '<': '&lt;', '>': '&gt;'};
return str.replace(/[&<>]/g, function (ch) {
return rep[ch] || ch;
});
}
return str;
}
ACOSWebdev.prototype.editorExecute = function (cb) {
var $iframe = $('<iframe src="about:blank"></iframe>');
this.$editorOutput.empty().append($iframe);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment