diff --git a/lib/haml/helpers/action_view_extensions.rb b/lib/haml/helpers/action_view_extensions.rb index 845546c2..35e346df 100644 --- a/lib/haml/helpers/action_view_extensions.rb +++ b/lib/haml/helpers/action_view_extensions.rb @@ -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 diff --git a/test/helper_test.rb b/test/helper_test.rb index c9040f46..97543220 100644 --- a/test/helper_test.rb +++ b/test/helper_test.rb @@ -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 "

" + end + + def render_something_with_haml_tag_and_concat + haml_tag 'p' do + haml_concat '' + 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

\n \n

\n<p>\n", output) + end + def test_flatten assert_equal("FooBar", Haml::Helpers.flatten("FooBar"))