Browse files

Escape intepolated code

  • Loading branch information...
1 parent 5b249e8 commit f46683deb1e66dfabb13a7a0582adc5f1e8f01ae @tj tj committed Dec 16, 2010
Showing with 2 additions and 1 deletion.
  1. +1 −1 lib/utils.js
  2. +1 −0 test/jade.test.js
View
2 lib/utils.js
@@ -17,7 +17,7 @@ var interpolate = exports.interpolate = function(str){
return str.replace(/(\\)?[#$]{(.*?)}/g, function(str, escape, code){
return escape
? str
- : "' + (" + code.replace(/\\'/g, "'") + ") + '";
+ : "' + escape(" + code.replace(/\\'/g, "'") + ") + '";
});
};
View
1 test/jade.test.js
@@ -323,6 +323,7 @@ module.exports = {
assert.equal('yo, jade is cool\n', render('| yo, #{name || "jade"} is cool', { locals: { name: null }}));
assert.equal('yo, \'jade\' is cool\n', render('| yo, #{name || "\'jade\'"} is cool', { locals: { name: null }}));
assert.equal('yo, jade is cool\n', render('| yo, ${name || \'jade\'} is cool', { locals: { name: null }}));
+ assert.equal('foo &lt;script&gt; bar\n', render('| foo #{code} bar', { locals: { code: '<script>' }}));
},
'test invalid indentation multiple': function(assert){

0 comments on commit f46683d

Please sign in to comment.