Skip to content

Commit a978caa

Browse files
committed
Fix DFL-3513: CDATA section breaks DOM and Scripts.
1 parent d2d4955 commit a978caa

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

src/ecma-debugger/helpers.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -115,22 +115,28 @@ window.cls.Helpers = function()
115115

116116
this.escapeTextHtml = (function()
117117
{
118-
var re_amp = /&/g, re_lt = /</g;
118+
var re_amp = /&/g;
119+
var re_lt = /</g;
120+
var re_cd_end = /]]>/g;
119121
return function(str)
120122
{
121-
return str ? str.replace(re_amp, "&amp;").replace(re_lt, "&lt;") : str;
123+
return str ? str.replace(re_amp, "&amp;")
124+
.replace(re_lt, "&lt;")
125+
.replace(re_cd_end, "]]&gt;")
126+
: str;
122127
}
123128
})();
124129

125130
this.escapeAttributeHtml = (function()
126131
{
127-
var re_amp = /&/g, re_lt = /</g, re_quot = /"/g, re_s_quot = /'/g;
132+
var re_quot = /"/g;
133+
var re_apos = /'/g;
128134
return function(str)
129135
{
130-
return str.replace(re_amp, "&amp;")
131-
.replace(re_lt, "&lt;")
132-
.replace(re_quot, "&quot;")
133-
.replace(re_s_quot, "&#x27;");
136+
return str ? this.escapeTextHtml(str)
137+
.replace(re_quot, "&quot;")
138+
.replace(re_apos, "&#x27;")
139+
: str;
134140
}
135141
})();
136142

src/syntaxhighlight/js/tokenizer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ cls.SimpleJSParser.prototype = new function()
5757
* @param {String} script_source The script string.
5858
* @param {Function} ontoken. Signature of the callback is (token_type, token).
5959
* @param {String} escape. Optional. Currently supports only "html"
60-
* to escape "<" and "&" to "&lt;" and "&amp;".
60+
* to escape "<", ">" and "&" to "&lt;", "&gt;" (for ]]>) and "&amp;".
6161
*/
6262
this.tokenize = function(script_source, ontoken, escape, start_state){};
6363

@@ -355,6 +355,7 @@ cls.SimpleJSParser.prototype = new function()
355355
var ESCAPE =
356356
{
357357
'<': '&lt;',
358+
'>': '&gt;',
358359
'&': '&amp;'
359360
}
360361
var default_parser=function(c)

0 commit comments

Comments
 (0)