Permalink
Browse files

HTML safety: fix textarea with nil content

  • Loading branch information...
1 parent b5f9c88 commit d8d38bedfd5716d55e50e85dc6c9a938b1848e66 @jeremy jeremy committed May 25, 2010
@@ -293,7 +293,7 @@ def text_area_tag(name, content = nil, options = {})
escape = options.key?("escape") ? options.delete("escape") : true
content = html_escape(content) if escape
- content_tag :textarea, content.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
+ content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
end
# Creates a check box form input tag.
@@ -206,6 +206,12 @@ def test_text_area_tag_unescaped_content
assert_dom_equal expected, actual
end
+ def test_text_area_tag_unescaped_nil_content
+ actual = text_area_tag "body", nil, :escape => false
+ expected = %(<textarea id="body" name="body"></textarea>)
+ assert_dom_equal expected, actual
+ end
+
def test_text_field_tag
actual = text_field_tag "title", "Hello!"
expected = %(<input id="title" name="title" type="text" value="Hello!" />)

0 comments on commit d8d38be

Please sign in to comment.