Merge pull request #36981 from tsuka/fix-tag-builder
Prevent TagBuilder modify options
This commit is contained in:
commit
4df0563dc5
@ -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=\""\" />", 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?
|
||||
|
Loading…
Reference in New Issue
Block a user