Skip to content

Commit

Permalink
Strip out slash-escaped JSON sequence received in client.
Browse files Browse the repository at this point in the history
The server will slash-escape some JSON related characters before sending. Need to strip them out before using, on the client side.
  • Loading branch information
pjhggns authored and nbaars committed May 2, 2018
1 parent 5d28ef9 commit 6a5ca43
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,23 @@ define(['jquery',
return false;
},

removeSlashesFromJSON: function(str) {
// slashes are leftover escapes from JSON serialization by server
// for every two char sequence starting with backslash,
// replace them in the text with second char only
return str.replace(/\\(.)/g, "$1");
},

renderFeedback: function(feedback) {
this.$curFeedback.html(polyglot.t(feedback) || "");
var s = this.removeSlashesFromJSON(feedback);
this.$curFeedback.html(polyglot.t(s) || "");
this.$curFeedback.show(400)

},

renderOutput: function(output) {
this.$curOutput.html(polyglot.t(output) || "");
var s = this.removeSlashesFromJSON(output);
this.$curOutput.html(polyglot.t(s) || "");
this.$curOutput.show(400)
},

Expand Down

0 comments on commit 6a5ca43

Please sign in to comment.