aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKieran Pilkington <kieran@katipo.co.nz>2010-04-04 16:31:52 +1200
committerXavier Noria <fxn@hashref.com>2010-04-16 15:05:41 -0700
commit001ca893c6f061796a2c3f03c864fdf06c9efbb1 (patch)
tree99eb36fe4d3716712cf61e18db28c7675886183e
parent66b55dbfea370f0c4553e7d65b468dfaa81e8b37 (diff)
downloadrails-001ca893c6f061796a2c3f03c864fdf06c9efbb1.tar.gz
rails-001ca893c6f061796a2c3f03c864fdf06c9efbb1.tar.bz2
rails-001ca893c6f061796a2c3f03c864fdf06c9efbb1.zip
Mark the result of grouped_options_for_select as HTML safe [#4322 state:committed]
Signed-off-by: Xavier Noria <fxn@hashref.com>
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb2
-rw-r--r--actionpack/test/template/form_options_helper_test.rb4
2 files changed, 5 insertions, 1 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index 105f4565e6..8f8db548c3 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -444,7 +444,7 @@ module ActionView
body << content_tag(:optgroup, options_for_select(group[1], selected_key), :label => group[0])
end
- body
+ body.html_safe
end
# Returns a string of option tags for pretty much any time zone in the
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 5799e3db53..98503c32fd 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -207,6 +207,10 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_grouped_options_for_select_returns_html_safe_string
+ assert grouped_options_for_select([["Hats", ["Baseball Cap","Cowboy Hat"]]]).html_safe?
+ end
+
def test_optgroups_with_with_options_with_hash
assert_dom_equal(
"<optgroup label=\"Europe\"><option value=\"Denmark\">Denmark</option>\n<option value=\"Germany\">Germany</option></optgroup><optgroup label=\"North America\"><option value=\"United States\">United States</option>\n<option value=\"Canada\">Canada</option></optgroup>",