Permalink
Browse files

Fixed that TextHelper#text_field would corrypt when raw HTML was used…

… as the value (mchenryc, Kevin Glowacz) [#80 state:resolved]
  • Loading branch information...
1 parent 12288a0 commit f6ec296ad84ac7e321980cfdd8bba2ea6ce3a14b @dhh dhh committed May 1, 2008
View
@@ -1,5 +1,7 @@
*SVN*
+* Fixed that TextHelper#text_field would corrypt when raw HTML was used as the value (mchenryc, Kevin Glowacz) [#80]
+
* Added ActionController::TestCase#rescue_action_in_public! to control whether the action under test should use the regular rescue_action path instead of simply raising the exception inline (great for error testing) [DHH]
* Reduce number of instance variables being copied from controller to view. [Pratik]
@@ -486,6 +486,7 @@ def to_input_field_tag(field_type, options = {})
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
@@ -104,6 +104,14 @@ def test_text_field_with_escapes
)
end
+ def test_text_field_with_html_entities
+ @post.title = "The HTML Entity for & is &"
+ assert_dom_equal(
+ '<input id="post_title" name="post[title]" size="30" type="text" value="The HTML Entity for &amp; is &amp;amp;" />',
+ text_field("post", "title")
+ )
+ end
+
def test_text_field_with_options
expected = '<input id="post_title" name="post[title]" size="35" type="text" value="Hello World" />'
assert_dom_equal expected, text_field("post", "title", "size" => 35)
@@ -227,6 +235,14 @@ def test_text_area_with_alternate_value
)
end
+ def test_text_area_with_html_entities
+ @post.body = "The HTML Entity for & is &amp;"
+ assert_dom_equal(
+ '<textarea cols="40" id="post_body" name="post[body]" rows="20">The HTML Entity for &amp; is &amp;amp;</textarea>',
+ text_area("post", "body")
+ )
+ end
+
def test_text_area_with_size_option
assert_dom_equal(
'<textarea cols="183" id="post_body" name="post[body]" rows="820">Back to the hill and over it again!</textarea>',

0 comments on commit f6ec296

Please sign in to comment.