mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Fixed HTML escaping after call to html_tag
The old value of _haml_concat_raw was not being set correctly, hence calls to haml_concat after a call to haml_tag would result in the output of haml_concat being appeneded unescaped. Resolves #718
This commit is contained in:
parent
c12ea707c7
commit
4d575c178c
2 changed files with 20 additions and 1 deletions
|
@ -45,8 +45,8 @@ module Haml
|
|||
# @yield A block in which all input to `#haml_concat` is treated as raw.
|
||||
# @see Haml::Util#rails_xss_safe?
|
||||
def with_raw_haml_concat
|
||||
old = instance_variable_defined?('@_haml_concat_raw') ? @_haml_concat_raw : false
|
||||
@_haml_concat_raw = true
|
||||
old = @_haml_concat_raw
|
||||
yield
|
||||
ensure
|
||||
@_haml_concat_raw = old
|
||||
|
|
|
@ -14,6 +14,16 @@ module Haml::Helpers
|
|||
def something_that_uses_haml_concat
|
||||
haml_concat('foo').to_s
|
||||
end
|
||||
|
||||
def render_something_with_haml_concat
|
||||
haml_concat "<p>"
|
||||
end
|
||||
|
||||
def render_something_with_haml_tag_and_concat
|
||||
haml_tag 'p' do
|
||||
haml_concat '<foo>'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class HelperTest < MiniTest::Unit::TestCase
|
||||
|
@ -42,6 +52,15 @@ class HelperTest < MiniTest::Unit::TestCase
|
|||
super
|
||||
end
|
||||
|
||||
def test_rendering_with_escapes
|
||||
output = render(<<-HAML, :action_view)
|
||||
- render_something_with_haml_concat
|
||||
- render_something_with_haml_tag_and_concat
|
||||
- render_something_with_haml_concat
|
||||
HAML
|
||||
assert_equal("<p>\n<p>\n <foo>\n</p>\n<p>\n", output)
|
||||
end
|
||||
|
||||
def test_flatten
|
||||
assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue