Add more characters that should not be un-escaped in regexps.

This commit is contained in:
Stefan Bethke 2016-09-30 15:17:05 +02:00
parent b4f8e7dc7b
commit 75e5f6edf9

View File

@ -134,7 +134,7 @@ function OutputStream(options) {
function make_string(str, quote) {
var dq = 0, sq = 0;
str = str.replace(/[\\\b\f\n\r\v\t\x1f\x22\x27\u2028\u2029\0\ufeff\uffff]/g,
str = str.replace(/[\\\b\f\n\r\v\t\x1f\x22\x27\u2028\u2029\0\ufeff\ufffe\uffff]/g,
function(s, i){
switch (s) {
case '"': ++dq; return '"';
@ -150,6 +150,7 @@ function OutputStream(options) {
case "\u2028": return "\\u2028";
case "\u2029": return "\\u2029";
case "\ufeff": return "\\ufeff";
case "\ufffe": return "\\ufffe";
case "\uffff": return "\\uffff";
case "\0":
return /[0-7]/.test(str.charAt(i+1)) ? "\\x00" : "\\0";
@ -1285,6 +1286,7 @@ function OutputStream(options) {
0x00 , // \0
0x1f ,
0xfeff , // Unicode BOM
0xfffe , // Unicode noncharacter
0xffff , // Unicode noncharacter
0x2028 , // unicode "line separator"
0x2029 , // unicode "paragraph separator"