fix \\n and \\r in template strings (#1857)

fixes #1856
This commit is contained in:
kzc
2017-04-30 05:05:32 -04:00
committed by Alex Lam S.L
parent 5c6316a37d
commit 73d6438773
2 changed files with 27 additions and 15 deletions

View File

@@ -171,17 +171,6 @@ function OutputStream(options) {
return '"' + str.replace(/\x22/g, '\\"') + '"';
}
function quote_template() {
if (!options.ascii_only) {
str = str.replace(/\\(n|r|u2028|u2029)/g, function(s, c) {
switch(c) {
case "n": return "\n";
case "r": return "\r";
case "u2028": return "\u2028";
case "u2029": return "\u2029";
}
return s;
});
}
return '`' + str.replace(/`/g, '\\`') + '`';
}
if (options.ascii_only) str = to_ascii(str);