summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormakoto kuwata <kwa@kuwata-lab.com>2010-06-27 15:52:18 +0900
committermakoto kuwata <kwa@kuwata-lab.com>2010-06-27 16:05:07 +0900
commit6a56d995dab1a7964245e16c6b76ae21145dee43 (patch)
treec9374df9b2916981e18c0585678d9484935c4b17
parent739314801168f7fa41a68a2e619fed530ec4eb1d (diff)
downloaderubis-6a56d995dab1a7964245e16c6b76ae21145dee43.tar.gz
[bugfix] fix a bug on InterporationEnhancer
-rw-r--r--lib/erubis/enhancer.rb2
-rw-r--r--test/test-enhancers.rb29
2 files changed, 29 insertions, 2 deletions
diff --git a/lib/erubis/enhancer.rb b/lib/erubis/enhancer.rb
index 2880f0e..d9b22a3 100644
--- a/lib/erubis/enhancer.rb
+++ b/lib/erubis/enhancer.rb
@@ -662,7 +662,7 @@ module Erubis
def _add_text_to_str(str, text)
return if !text || text.empty?
- text.gsub!(/['\#\\]/, '\\\\\&')
+ text.gsub!(/[`\#\\]/, '\\\\\&')
str << text
end
diff --git a/test/test-enhancers.rb b/test/test-enhancers.rb
index eb0fa7c..cf6dc82 100644
--- a/test/test-enhancers.rb
+++ b/test/test-enhancers.rb
@@ -567,4 +567,31 @@ __END__
_buf.to_s
output: *basic1_output
-
+- name: interpolation2
+ desc: sharp, back-quote, and backslash should be escaped, but other quotes should not be escaped (reported by andrewj)
+ class: InterpolationEruby
+ options:
+ testopt:
+ input: |
+ <p>`back-quote`</p>
+ <p><%= `echo back-tick operator` %></p>
+ <p>#{sharp}</p>
+ <p>'single quote'</p>
+ <p>"double quote"</p>
+ <p>backslash\n\t</p>
+ src: |
+ _buf = ''; _buf << %Q`<p>\`back-quote\`</p>
+ <p>#{ `echo back-tick operator` }</p>
+ <p>\#{sharp}</p>
+ <p>'single quote'</p>
+ <p>"double quote"</p>
+ <p>backslash\\n\\t</p>\n`
+ _buf.to_s
+ output: |
+ <p>`back-quote`</p>
+ <p>back-tick operator
+ </p>
+ <p>#{sharp}</p>
+ <p>'single quote'</p>
+ <p>"double quote"</p>
+ <p>backslash\n\t</p>