Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix DFL-3650 - need to escape control characters before parsing with …

…innerHTML.
  • Loading branch information...
commit ae9c59f40a75f665601dba4b59cc73d416c5292c 1 parent 6d79eed
@hzr hzr authored
View
7 src/ecma-debugger/helpers.js
@@ -118,11 +118,18 @@ window.cls.Helpers = function()
var re_amp = /&/g;
var re_lt = /</g;
var re_cd_end = /]]>/g;
+ var re_control_characters = /[\u0000-\u001f]/g;
return function(str)
{
return str ? str.replace(re_amp, "&amp;")
.replace(re_lt, "&lt;")
.replace(re_cd_end, "]]&gt;")
+ .replace(re_control_characters, function(c) {
+ // We can't set innerHTML with these characters in XML.
+ // Just replace them with blank, since they are very
+ // seldomly used.
+ return "";
+ })
@p01 Owner
p01 added a note

Note sure what's the best approach. But that will do as a quick-fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
: str;
}
})();
View
35 src/syntaxhighlight/js/tokenizer.js
@@ -356,7 +356,40 @@ cls.SimpleJSParser.prototype = new function()
{
'<': '&lt;',
'>': '&gt;',
- '&': '&amp;'
+ '&': '&amp;',
+ // The following control characters need to be escaped in XML.
+ '\u0000': '\\u0000',
+ '\u0001': '\\u0001',
+ '\u0002': '\\u0002',
+ '\u0003': '\\u0003',
+ '\u0004': '\\u0004',
+ '\u0005': '\\u0005',
+ '\u0006': '\\u0006',
+ '\u0007': '\\u0007',
+ '\u0008': '\\u0008',
+ '\u0009': '\\u0009',
+ '\u000a': '\\u000a',
+ '\u000b': '\\u000b',
+ '\u000c': '\\u000c',
+ '\u000d': '\\u000d',
+ '\u000e': '\\u000e',
+ '\u000f': '\\u000f',
+ '\u0010': '\\u0010',
+ '\u0011': '\\u0011',
+ '\u0012': '\\u0012',
+ '\u0013': '\\u0013',
+ '\u0014': '\\u0014',
+ '\u0015': '\\u0015',
+ '\u0016': '\\u0016',
+ '\u0017': '\\u0017',
+ '\u0018': '\\u0018',
+ '\u0019': '\\u0019',
+ '\u001a': '\\u001a',
+ '\u001b': '\\u001b',
+ '\u001c': '\\u001c',
+ '\u001d': '\\u001d',
+ '\u001e': '\\u001e',
+ '\u001f': '\\u001f'
}
var default_parser=function(c)
{
Please sign in to comment.
Something went wrong with that request. Please try again.