From 399b493cb454e6f6dd1a310ba31adaa8e6550830 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Sun, 6 Jun 2010 02:20:45 -0300 Subject: [PATCH] content_tag_string shouldn't escape_html if escape param is false --- actionpack/lib/action_view/helpers/tag_helper.rb | 2 +- actionpack/test/template/tag_helper_test.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/tag_helper.rb b/actionpack/lib/action_view/helpers/tag_helper.rb index c09d01eeee96c..66277f79fe8c3 100644 --- a/actionpack/lib/action_view/helpers/tag_helper.rb +++ b/actionpack/lib/action_view/helpers/tag_helper.rb @@ -110,7 +110,7 @@ def escape_once(html) def content_tag_string(name, content, options, escape = true) tag_options = tag_options(options, escape) if options - "<#{name}#{tag_options}>#{ERB::Util.h(content)}".html_safe + "<#{name}#{tag_options}>#{escape ? ERB::Util.h(content) : content}".html_safe end def tag_options(options, escape = true) diff --git a/actionpack/test/template/tag_helper_test.rb b/actionpack/test/template/tag_helper_test.rb index 256d9bdcde862..ec5fe3d1d76e5 100644 --- a/actionpack/test/template/tag_helper_test.rb +++ b/actionpack/test/template/tag_helper_test.rb @@ -39,6 +39,8 @@ def test_content_tag content_tag("a", "Create", :href => "create") assert_equal "

<script>evil_js</script>

", content_tag(:p, '') + assert_equal "

", + content_tag(:p, '', nil, false) end def test_content_tag_with_block_in_erb