From 921a9c085d682c908880a8ce2c0af716575e5420 Mon Sep 17 00:00:00 2001 From: Kevin Glowacz Date: Thu, 1 May 2008 10:28:45 -0500 Subject: [PATCH] Text field with html entities --- actionpack/lib/action_view/helpers/form_helper.rb | 1 + actionpack/test/template/form_helper_test.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 4459ccb..65f4fb6 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -486,6 +486,7 @@ module ActionView end options["type"] = field_type options["value"] ||= value_before_type_cast(object) unless field_type == "file" + options["value"] &&= html_escape(options["value"]) add_default_name_and_id(options) tag("input", options) end diff --git a/actionpack/test/template/form_helper_test.rb b/actionpack/test/template/form_helper_test.rb index b4857fc..204575f 100644 --- a/actionpack/test/template/form_helper_test.rb +++ b/actionpack/test/template/form_helper_test.rb @@ -104,6 +104,14 @@ class FormHelperTest < ActionView::TestCase ) end + def test_text_field_with_html_entities + @post.title = "The HTML Entity for & is &" + assert_dom_equal( + '', + text_field("post", "title") + ) + end + def test_text_field_with_options expected = '' assert_dom_equal expected, text_field("post", "title", "size" => 35) @@ -227,6 +235,14 @@ class FormHelperTest < ActionView::TestCase ) end + def test_text_area_with_html_entities + @post.body = "The HTML Entity for & is &" + assert_dom_equal( + '', + text_area("post", "body") + ) + end + def test_text_area_with_size_option assert_dom_equal( '', -- 1.5.5.1