[Haml] Fix interpolated if statements with HTML-escaping.

This commit is contained in:
Nathan Weizenbaum 2010-09-28 23:36:10 -07:00
parent c5e91fe41f
commit 144c93ff0a
3 changed files with 11 additions and 1 deletions

View File

@ -7,6 +7,8 @@
* Fix the `:encoding` option under Ruby 1.9.2. * Fix the `:encoding` option under Ruby 1.9.2.
* Fix interpolated if statement when HTML escaping is enabled.
* Allow the `--unix-newlines` flag to work on Unix, where it's a no-op. * Allow the `--unix-newlines` flag to work on Unix, where it's a no-op.
## 3.0.18 ## 3.0.18

View File

@ -1024,7 +1024,7 @@ END
res << '#{' res << '#{'
else else
content = eval('"' + balance(scan, ?{, ?}, 1)[0][0...-1] + '"') content = eval('"' + balance(scan, ?{, ?}, 1)[0][0...-1] + '"')
content = "Haml::Helpers.html_escape(#{content})" if opts[:escape_html] content = "Haml::Helpers.html_escape((#{content}))" if opts[:escape_html]
res << '#{' + content + "}"# Use eval to get rid of string escapes res << '#{' + content + "}"# Use eval to get rid of string escapes
end end
end end

View File

@ -774,6 +774,14 @@ HTML
HAML HAML
end end
def test_escape_html_with_interpolated_if_statement
assert_equal(<<HTML, render(<<HAML, :escape_html => true))
foo,
HTML
foo\#{"," if true}
HAML
end
# HTML escaping tests # HTML escaping tests
def test_ampersand_equals_should_escape def test_ampersand_equals_should_escape