Permalink
Browse files

HTML safety: fix textarea with nil content

  • Loading branch information...
1 parent aa44914 commit 6a9e188c0c925634749478eb7cde43aead9b133f @jeremy jeremy committed May 25, 2010
@@ -265,7 +265,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.stringify_keys)
+ content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options.stringify_keys)
end
# Creates a check box form input tag.
@@ -176,6 +176,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 6a9e188

Please sign in to comment.