aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/output_safety_helper.rb
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2014-06-13 08:45:23 +0930
committerMatthew Draper <matthew@trebex.net>2014-06-13 08:52:44 +0930
commit6857415187810f1289068a448268264d0cf0844f (patch)
treedcda70dc09680f967e20c60462563b29aa3c0a42 /actionview/lib/action_view/helpers/output_safety_helper.rb
parent4e009eec3dacf76d25f61402f86b2e474dadee8a (diff)
parentbcab3f20dac0fe993e5d31bf6acef28ec54e658b (diff)
downloadrails-6857415187810f1289068a448268264d0cf0844f.tar.gz
rails-6857415187810f1289068a448268264d0cf0844f.tar.bz2
rails-6857415187810f1289068a448268264d0cf0844f.zip
Merge pull request #15654 from pdg137/master
In tag helper, honor html_safe on arrays; also make safe_join more similar to Array.join
Diffstat (limited to 'actionview/lib/action_view/helpers/output_safety_helper.rb')
-rw-r--r--actionview/lib/action_view/helpers/output_safety_helper.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/output_safety_helper.rb b/actionview/lib/action_view/helpers/output_safety_helper.rb
index e1f40011c0..b0d9c7c7f9 100644
--- a/actionview/lib/action_view/helpers/output_safety_helper.rb
+++ b/actionview/lib/action_view/helpers/output_safety_helper.rb
@@ -18,9 +18,9 @@ module ActionView #:nodoc:
end
# This method returns a html safe string similar to what <tt>Array#join</tt>
- # would return. All items in the array, including the supplied separator, are
- # html escaped unless they are html safe, and the returned string is marked
- # as html safe.
+ # would return. The array is flattened, and all items, including
+ # the supplied separator, are html escaped unless they are html
+ # safe, and the returned string is marked as html safe.
#
# safe_join(["<p>foo</p>".html_safe, "<p>bar</p>"], "<br />")
# # => "<p>foo</p>&lt;br /&gt;&lt;p&gt;bar&lt;/p&gt;"
@@ -31,7 +31,7 @@ module ActionView #:nodoc:
def safe_join(array, sep=$,)
sep = ERB::Util.unwrapped_html_escape(sep)
- array.map { |i| ERB::Util.unwrapped_html_escape(i) }.join(sep).html_safe
+ array.flatten.map! { |i| ERB::Util.unwrapped_html_escape(i) }.join(sep).html_safe
end
end
end