Escape interpolation

This commit is contained in:
Takashi Kokubun 2015-10-15 23:10:31 +09:00
parent c97f17d7ed
commit e2da721bc5
2 changed files with 6 additions and 8 deletions

View File

@ -12,11 +12,9 @@ module Hamlit
text = node.value[:text].rstrip
if Haml::Util.contains_interpolation?(text)
# FIXME: Confirm whether this is correct or not
if @pretty
[:dynamic, Haml::Util.unescape_interpolation(text)]
else
[:dynamic, Haml::Util.unescape_interpolation(text + "\n")]
end
text << "\n".freeze unless @pretty
text = Haml::Util.unescape_interpolation(text)
[:escape, true, [:dynamic, text]]
else
[:static, text]
end

View File

@ -66,7 +66,7 @@ class FiltersTest < Haml::TestCase
end
end
test "should respect escaped newlines and interpolation" do; skip
test "should respect escaped newlines and interpolation" do
html = "\\n\n"
haml = ":plain\n \\n\#{""}"
assert_equal(html, render(haml))
@ -117,7 +117,7 @@ class FiltersTest < Haml::TestCase
end
end
test "interpolated code should be escaped if escape_html is set" do; skip
test "interpolated code should be escaped if escape_html is set" do
assert_equal "&lt;script&gt;evil&lt;/script&gt;\n",
render(":plain\n \#{'<script>evil</script>'}", :escape_html => true)
end
@ -264,4 +264,4 @@ class RubyFilterTest < Haml::TestCase
html = "7\n"
assert_equal(html, render(haml))
end
end
end