Skip to content
This repository
Browse code

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 Holowaychuk authored

Showing 2 changed files with 9 additions and 4 deletions. Show diff stats Hide diff stats

  1. +2 1  lib/compiler.js
  2. +7 3 lib/utils.js
3  lib/compiler.js
@@ -435,8 +435,9 @@ Compiler.prototype = {
435 435 */
436 436
437 437 visitText: function(text){
438   - text = utils.text(text.val.replace(/\\/g, '\\\\'));
  438 + text = utils.text(text.val.replace(/\\/g, '_SLASH_'));
439 439 if (this.escape) text = escape(text);
  440 + text = text.replace(/_SLASH_/g, '\\\\');
440 441 this.buffer(text);
441 442 },
442 443
10 lib/utils.js
@@ -14,12 +14,16 @@
14 14 */
15 15
16 16 var interpolate = exports.interpolate = function(str){
17   - return str.replace(/(\\)?([#!]){(.*?)}/g, function(str, escape, flag, code){
  17 + return str.replace(/(_SLASH_)?([#!]){(.*?)}/g, function(str, escape, flag, code){
  18 + code = code
  19 + .replace(/\\'/g, "'")
  20 + .replace(/_SLASH_/g, '\\');
  21 +
18 22 return escape
19   - ? str.slice(1)
  23 + ? str.slice(7)
20 24 : "' + "
21 25 + ('!' == flag ? '' : 'escape')
22   - + "((interp = " + code.replace(/\\'/g, "'")
  26 + + "((interp = " + code
23 27 + ") == null ? '' : interp) + '";
24 28 });
25 29 };

0 comments on commit 30c173d

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