未验证 提交 e7bd6517 编写于 作者: R Rafael França 提交者: Rafael Mendonça França

Merge pull request #36981 from tsuka/fix-tag-builder

Prevent TagBuilder modify options
上级 26aabdcc
......@@ -88,7 +88,7 @@ def tag_option(key, value, escape)
if value.is_a?(Array)
value = escape ? safe_join(value, " ") : value.join(" ")
else
value = escape ? ERB::Util.unwrapped_html_escape(value) : value.to_s.dup
value = escape ? ERB::Util.unwrapped_html_escape(value).dup : value.to_s.dup
end
value.gsub!('"', """)
%(#{key}="#{value}")
......
......@@ -79,6 +79,13 @@ def test_tag_builder_options_converts_boolean_option
tag.p(disabled: true, itemscope: true, multiple: true, readonly: true, allowfullscreen: true, seamless: true, typemustmatch: true, sortable: true, default: true, inert: true, truespeed: true)
end
def test_tag_builder_do_not_modify_html_safe_options
html_safe_str = '"'.html_safe
assert_equal "<p value=\"&quot;\" />", tag("p", value: html_safe_str)
assert_equal '"', html_safe_str
assert html_safe_str.html_safe?
end
def test_content_tag
assert_equal "<a href=\"create\">Create</a>", content_tag("a", "Create", "href" => "create")
assert_predicate content_tag("a", "Create", "href" => "create"), :html_safe?
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册