Skip to content

Commit ae9c59f

Browse files
committed
Fix DFL-3650 - need to escape control characters before parsing with innerHTML.
1 parent 6d79eed commit ae9c59f

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/ecma-debugger/helpers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,18 @@ window.cls.Helpers = function()
118118
var re_amp = /&/g;
119119
var re_lt = /</g;
120120
var re_cd_end = /]]>/g;
121+
var re_control_characters = /[\u0000-\u001f]/g;
121122
return function(str)
122123
{
123124
return str ? str.replace(re_amp, "&amp;")
124125
.replace(re_lt, "&lt;")
125126
.replace(re_cd_end, "]]&gt;")
127+
.replace(re_control_characters, function(c) {
128+
// We can't set innerHTML with these characters in XML.
129+
// Just replace them with blank, since they are very
130+
// seldomly used.
131+
return "";
132+
})
126133
: str;
127134
}
128135
})();

src/syntaxhighlight/js/tokenizer.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,40 @@ cls.SimpleJSParser.prototype = new function()
356356
{
357357
'<': '&lt;',
358358
'>': '&gt;',
359-
'&': '&amp;'
359+
'&': '&amp;',
360+
// The following control characters need to be escaped in XML.
361+
'\u0000': '\\u0000',
362+
'\u0001': '\\u0001',
363+
'\u0002': '\\u0002',
364+
'\u0003': '\\u0003',
365+
'\u0004': '\\u0004',
366+
'\u0005': '\\u0005',
367+
'\u0006': '\\u0006',
368+
'\u0007': '\\u0007',
369+
'\u0008': '\\u0008',
370+
'\u0009': '\\u0009',
371+
'\u000a': '\\u000a',
372+
'\u000b': '\\u000b',
373+
'\u000c': '\\u000c',
374+
'\u000d': '\\u000d',
375+
'\u000e': '\\u000e',
376+
'\u000f': '\\u000f',
377+
'\u0010': '\\u0010',
378+
'\u0011': '\\u0011',
379+
'\u0012': '\\u0012',
380+
'\u0013': '\\u0013',
381+
'\u0014': '\\u0014',
382+
'\u0015': '\\u0015',
383+
'\u0016': '\\u0016',
384+
'\u0017': '\\u0017',
385+
'\u0018': '\\u0018',
386+
'\u0019': '\\u0019',
387+
'\u001a': '\\u001a',
388+
'\u001b': '\\u001b',
389+
'\u001c': '\\u001c',
390+
'\u001d': '\\u001d',
391+
'\u001e': '\\u001e',
392+
'\u001f': '\\u001f'
360393
}
361394
var default_parser=function(c)
362395
{

0 commit comments

Comments
 (0)