Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Escape unicode newlines in string literals

Fixes #375
  • Loading branch information...
commit 4d66d0c0a688206c1b637b9d02da4a77eb5d1f71 1 parent bee0fac
@kpdecker kpdecker authored
View
4 dist/handlebars.js
@@ -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) {
View
4 lib/handlebars/compiler/compiler.js
@@ -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) {
View
4 spec/qunit_spec.js
@@ -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() {
Please sign in to comment.
Something went wrong with that request. Please try again.