Fully restore standard functionality; all addional escaping is now properly hidden behind xml_safe

This commit is contained in:
Stefan Bethke 2016-10-04 18:27:33 +02:00
parent 9c0ecd3fa1
commit c04a343e29
3 changed files with 8 additions and 9 deletions

View File

@ -137,7 +137,7 @@ function OutputStream(options) {
var dq = 0, sq = 0; var dq = 0, sq = 0;
var re = options.xml_safe ? var re = options.xml_safe ?
/[\x00-\x1f\x22\x27\u2028\u2029\0\ud800-\udfff\ufeff\ufffe\uffff]/g : /[\x00-\x1f\x22\x27\u2028\u2029\0\ud800-\udfff\ufeff\ufffe\uffff]/g :
/[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff\uffff]/g; /[\\\b\f\n\r\v\t\x22\x27\u2028\u2029\0\ufeff]/g;
str = str.replace(re, str = str.replace(re,
function(s, i){ function(s, i){
switch (s) { switch (s) {
@ -1270,7 +1270,7 @@ function OutputStream(options) {
0x08, 0x0c, 0x0e, 0x0f, 0x08, 0x0c, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0xfffe 0xfffe, 0xffff
].indexOf(code) >= 0) ].indexOf(code) >= 0)
return false; return false;
// C1 (except 0x85) and surrogate pair code points are invalid // C1 (except 0x85) and surrogate pair code points are invalid
@ -1300,7 +1300,6 @@ function OutputStream(options) {
0x0d , // \r 0x0d , // \r
0x00 , // \0 0x00 , // \0
0xfeff , // Unicode BOM 0xfeff , // Unicode BOM
0xffff , // Unicode noncharacter
0x2028 , // unicode "line separator" 0x2028 , // unicode "line separator"
0x2029 , // unicode "paragraph separator" 0x2029 , // unicode "paragraph separator"
].indexOf(code) < 0; ].indexOf(code) < 0;

View File

@ -10,13 +10,13 @@ ascii_only_true: {
return "\x000\x001\x007\x008\x00" + return "\x000\x001\x007\x008\x00" +
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" +
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" +
"\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\ufffe\uffff"; "\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\uffff";
} }
} }
expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b\\t\\n\\v\\f\\r\\x0e\\x0f"+"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f"+\' !"# ... }~\\x7f\\x80\\x81 ... \\xfe\\xff\\u0fff\\ufffe\\uffff\'}' expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07\\b\\t\\n\\v\\f\\r\\x0e\\x0f"+"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f"+\' !"# ... }~\\x7f\\x80\\x81 ... \\xfe\\xff\\u0fff\\uffff\'}'
} }
ascii_only_false: { // also tests xml_safe===false ascii_only_false: {
options = {} options = {}
beautify = { beautify = {
ascii_only : false, ascii_only : false,
@ -29,10 +29,10 @@ ascii_only_false: { // also tests xml_safe===false
return "\x000\x001\x007\x008\x00" + return "\x000\x001\x007\x008\x00" +
"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" + "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f" +
"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" + "\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f" +
"\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\ufffe\uffff"; "\x20\x21\x22\x23 ... \x7d\x7e\x7f\x80\x81 ... \xfe\xff\u0fff\uffff";
} }
} }
expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\x01\x02\x03\x04\x05\x06\x07\\b\\t\\n\\v\\f\\r\x0e\x0f"+"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"+\' !"# ... }~\x7f\x80\x81 ... \xfe\xff\u0fff\ufffe\\uffff\'}' expect_exact: 'function f(){return"\\x000\\x001\\x007\\08\\0"+"\\0\x01\x02\x03\x04\x05\x06\x07\\b\\t\\n\\v\\f\\r\x0e\x0f"+"\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e\x1f"+\' !"# ... }~\x7f\x80\x81 ... \xfe\xff\u0fff\uffff\'}'
} }
xml_safe_true: { xml_safe_true: {

View File

@ -12,7 +12,7 @@ regexp: {
return /[\x00\x0d\x1f \x61\u0fff\ud800\ufffe\uffff]/; return /[\x00\x0d\x1f \x61\u0fff\ud800\ufffe\uffff]/;
} }
} }
expect_exact: 'function f(){return/[\\x00\\x0d\x1f a\u0fff\ud800\ufffe\\uffff]/}' expect_exact: 'function f(){return/[\\x00\\x0d\x1f a\u0fff\ud800\ufffe\uffff]/}'
} }
regexp_ascii_only_true: { regexp_ascii_only_true: {