Skip to content

Commit

Permalink
content_tag_string shouldn't escape_html if escape param is false
Browse files Browse the repository at this point in the history
  • Loading branch information
spastorino authored and wycats committed Jun 7, 2010
1 parent eebac02 commit 399b493
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/tag_helper.rb
Expand Up @@ -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)}</#{name}>".html_safe
"<#{name}#{tag_options}>#{escape ? ERB::Util.h(content) : content}</#{name}>".html_safe
end

def tag_options(options, escape = true)
Expand Down
2 changes: 2 additions & 0 deletions actionpack/test/template/tag_helper_test.rb
Expand Up @@ -39,6 +39,8 @@ def test_content_tag
content_tag("a", "Create", :href => "create")
assert_equal "<p>&lt;script&gt;evil_js&lt;/script&gt;</p>",
content_tag(:p, '<script>evil_js</script>')
assert_equal "<p><script>evil_js</script></p>",
content_tag(:p, '<script>evil_js</script>', nil, false)
end

def test_content_tag_with_block_in_erb
Expand Down

0 comments on commit 399b493

Please sign in to comment.