aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tag_helper.rb
diff options
context:
space:
mode:
authorPaul Grayson <paul@pololu.com>2014-06-10 17:33:34 -0700
committerPaul Grayson <paul@pololu.com>2014-06-12 15:30:40 -0700
commitbcab3f20dac0fe993e5d31bf6acef28ec54e658b (patch)
treef3fd8f027b75814410245c91aa87963be1c9f00a /actionview/lib/action_view/helpers/tag_helper.rb
parent80b4fe2c50feb295af64e1a8c960cfed4fd8ae19 (diff)
downloadrails-bcab3f20dac0fe993e5d31bf6acef28ec54e658b.tar.gz
rails-bcab3f20dac0fe993e5d31bf6acef28ec54e658b.tar.bz2
rails-bcab3f20dac0fe993e5d31bf6acef28ec54e658b.zip
In tag helper, honor html_safe on array parameters; also make safe_join more similar to Array.join by first calling flatten.
Diffstat (limited to 'actionview/lib/action_view/helpers/tag_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/tag_helper.rb18
1 files changed, 15 insertions, 3 deletions
diff --git a/actionview/lib/action_view/helpers/tag_helper.rb b/actionview/lib/action_view/helpers/tag_helper.rb
index 9b9ca7d60d..89a30d4b69 100644
--- a/actionview/lib/action_view/helpers/tag_helper.rb
+++ b/actionview/lib/action_view/helpers/tag_helper.rb
@@ -173,9 +173,21 @@ module ActionView
end
def tag_option(key, value, escape)
- value = value.join(" ") if value.is_a?(Array)
- value = ERB::Util.unwrapped_html_escape(value) if escape
- %(#{key}="#{value}")
+ escaped_value = case value
+ when Array
+ if escape
+ safe_join(value, " ")
+ else
+ value.join(" ")
+ end
+ else
+ if escape
+ ERB::Util.unwrapped_html_escape(value)
+ else
+ value
+ end
+ end
+ %(#{key}="#{escaped_value}")
end
end
end