Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix double-escaping of interpolated js slashes. Closes #784

lame fix since we dont actually tokenize
text nodes
  • Loading branch information...
commit 30c173dcbf13d363dacd6269543c4cfd1a67cb46 1 parent 06c9210
@tj tj authored
Showing with 9 additions and 4 deletions.
  1. +2 −1  lib/compiler.js
  2. +7 −3 lib/utils.js
View
3  lib/compiler.js
@@ -435,8 +435,9 @@ Compiler.prototype = {
*/
visitText: function(text){
- text = utils.text(text.val.replace(/\\/g, '\\\\'));
+ text = utils.text(text.val.replace(/\\/g, '_SLASH_'));
if (this.escape) text = escape(text);
+ text = text.replace(/_SLASH_/g, '\\\\');
this.buffer(text);
},
View
10 lib/utils.js
@@ -14,12 +14,16 @@
*/
var interpolate = exports.interpolate = function(str){
- return str.replace(/(\\)?([#!]){(.*?)}/g, function(str, escape, flag, code){
+ return str.replace(/(_SLASH_)?([#!]){(.*?)}/g, function(str, escape, flag, code){
+ code = code
+ .replace(/\\'/g, "'")
+ .replace(/_SLASH_/g, '\\');
+
return escape
- ? str.slice(1)
+ ? str.slice(7)
: "' + "
+ ('!' == flag ? '' : 'escape')
- + "((interp = " + code.replace(/\\'/g, "'")
+ + "((interp = " + code
+ ") == null ? '' : interp) + '";
});
};

0 comments on commit 30c173d

Please sign in to comment.
Something went wrong with that request. Please try again.