aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template/form_options_helper_test.rb
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2012-02-20 15:19:28 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-20 15:19:28 -0800
commit08b029cd245a304fd204081c1c7f2a96ce32f4c6 (patch)
treea6e9c4ff940848d4152b66d9a482e0f5a0aa91cb /actionpack/test/template/form_options_helper_test.rb
parent563df87f19d21eb491f1c24dab0f59682fe0a737 (diff)
downloadrails-08b029cd245a304fd204081c1c7f2a96ce32f4c6.tar.gz
rails-08b029cd245a304fd204081c1c7f2a96ce32f4c6.tar.bz2
rails-08b029cd245a304fd204081c1c7f2a96ce32f4c6.zip
fix output safety issue with select options
Diffstat (limited to 'actionpack/test/template/form_options_helper_test.rb')
-rw-r--r--actionpack/test/template/form_options_helper_test.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/actionpack/test/template/form_options_helper_test.rb b/actionpack/test/template/form_options_helper_test.rb
index 6b8d62df62..606d454cb3 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -509,7 +509,7 @@ class FormOptionsHelperTest < ActionView::TestCase
def test_select_under_fields_for_with_string_and_given_prompt
@post = Post.new
- options = "<option value=\"abe\">abe</option><option value=\"mus\">mus</option><option value=\"hest\">hest</option>"
+ options = "<option value=\"abe\">abe</option><option value=\"mus\">mus</option><option value=\"hest\">hest</option>".html_safe
output_buffer = fields_for :post, @post do |f|
concat f.select(:category, options, :prompt => 'The prompt')
@@ -665,6 +665,13 @@ class FormOptionsHelperTest < ActionView::TestCase
)
end
+ def test_select_escapes_options
+ assert_dom_equal(
+ '<select id="post_title" name="post[title]">&lt;script&gt;alert(1)&lt;/script&gt;</select>',
+ select('post', 'title', '<script>alert(1)</script>')
+ )
+ end
+
def test_select_with_selected_nil
@post = Post.new
@post.category = "<mus>"