This commit is contained in:
Jason Davies 2014-12-27 19:34:35 +00:00
commit 694b023e60

View File

@ -86,7 +86,7 @@ function OutputStream(options) {
function make_string(str) {
var dq = 0, sq = 0;
str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s){
str = str.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g, function(s, i){
switch (s) {
case "\\": return "\\\\";
case "\b": return "\\b";
@ -97,7 +97,9 @@ function OutputStream(options) {
case "\u2029": return "\\u2029";
case '"': ++dq; return '"';
case "'": ++sq; return "'";
case "\0": return "\\x00";
case "\0":
var next = str.charCodeAt(i + 1);
return 48 <= next && next <= 57 ? "\\x00" : "\\0";
}
return s;
});