aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/template
diff options
context:
space:
mode:
authorSergey Nartimov <just.lest@gmail.com>2012-02-20 15:41:17 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-02-20 15:41:17 -0800
commit7b73913701ff41981d166ca457e41690aac3bce3 (patch)
tree8badfe64d7a783fb19d3e3756c186fb539e054c8 /actionpack/test/template
parentb80d8f71112279f989ad3accbfed277a25cedd57 (diff)
downloadrails-7b73913701ff41981d166ca457e41690aac3bce3.tar.gz
rails-7b73913701ff41981d166ca457e41690aac3bce3.tar.bz2
rails-7b73913701ff41981d166ca457e41690aac3bce3.zip
fix output safety issue with select options
Diffstat (limited to 'actionpack/test/template')
-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 62ab208c2e..5b19bcf0f9 100644
--- a/actionpack/test/template/form_options_helper_test.rb
+++ b/actionpack/test/template/form_options_helper_test.rb
@@ -495,7 +495,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')
@@ -651,6 +651,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>"