Escape unicode newlines in string literals

Fixes #375
This commit is contained in:
kpdecker
2013-04-06 16:42:24 -05:00
parent bee0facaca
commit 4d66d0c0a6
3 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -1971,7 +1971,9 @@ JavaScriptCompiler.prototype = {
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r') + '"';
.replace(/\r/g, '\\r')
.replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
.replace(/\u2029/g, '\\u2029') + '"';
},
setupHelper: function(paramSize, name, missingParams) {
+3 -1
View File
@@ -1130,7 +1130,9 @@ JavaScriptCompiler.prototype = {
.replace(/\\/g, '\\\\')
.replace(/"/g, '\\"')
.replace(/\n/g, '\\n')
.replace(/\r/g, '\\r') + '"';
.replace(/\r/g, '\\r')
.replace(/\u2028/g, '\\u2028') // Per Ecma-262 7.3 + 7.8.4
.replace(/\u2029/g, '\\u2029') + '"';
},
setupHelper: function(paramSize, name, missingParams) {
+4
View File
@@ -1408,6 +1408,10 @@ test('GH-458: Scoped this identifier', function() {
shouldCompileTo('{{./foo}}', {foo: 'bar'}, 'bar');
});
test('GH-375: Unicode line terminators', function() {
shouldCompileTo('\u2028', {}, '\u2028');
});
suite('Utils');
test('escapeExpression', function() {