提交 399b493c 编写于 作者: S Santiago Pastorino 提交者: wycats

content_tag_string shouldn't escape_html if escape param is false

上级 eebac026
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册