Escape template delimiters before using them in a RegExp

This commit is contained in:
Rick Fletcher
2010-02-23 23:47:28 -08:00
parent 38a82591b1
commit 3482ec1259
2 changed files with 4 additions and 4 deletions

View File

@@ -576,7 +576,7 @@
'var p=[],print=function(){p.push.apply(p,arguments);};' +
'with(obj){p.push(\'' +
str.replace(/[\r\t\n]/g, " ")
.replace(new RegExp("'(?=[^"+c.end[0]+"]*"+c.end+")","g"),"\t")
.replace(new RegExp("'(?=[^"+c.end[0]+"]*\\"+c.end.split('').join("\\")+")","g"),"\t")
.split("'").join("\\'")
.split("\t").join("'")
.replace(c.interpolate, "',$1,'")