Skip to content

Commit

Permalink
strip_tags passes through blank args such as nil or "". Closes #6702,…
Browse files Browse the repository at this point in the history
… references #2229.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5629 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Nov 26, 2006
1 parent eacca8d commit 1d564d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion actionpack/CHANGELOG
Expand Up @@ -268,7 +268,7 @@


* radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com] * radio_button_tag generates unique id attributes. #3353 [Bob Silva, somekool@gmail.com]


* strip_tags returns nil for a blank arg such as nil or "". #2229 [duncan@whomwah.com] * strip_tags passes through blank args such as nil or "". #2229, #6702 [duncan@whomwah.com, dharana]


* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com] * Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com]


Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_view/helpers/text_helper.rb
Expand Up @@ -254,7 +254,7 @@ def sanitize(html)
# html-scanner tokenizer and so its HTML parsing ability is limited by # html-scanner tokenizer and so its HTML parsing ability is limited by
# that of html-scanner. # that of html-scanner.
def strip_tags(html) def strip_tags(html)
return nil if html.blank? return html if html.blank?
if html.index("<") if html.index("<")
text = "" text = ""
tokenizer = HTML::Tokenizer.new(html) tokenizer = HTML::Tokenizer.new(html)
Expand Down
2 changes: 1 addition & 1 deletion actionpack/test/template/text_helper_test.rb
Expand Up @@ -321,6 +321,6 @@ def test_strip_tags
%{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags( %{This is a test.\n\n\nIt no longer contains any HTML.\n}, strip_tags(
%{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n})) %{<title>This is <b>a <a href="" target="_blank">test</a></b>.</title>\n\n<!-- it has a comment -->\n\n<p>It no <b>longer <strong>contains <em>any <strike>HTML</strike></em>.</strong></b></p>\n}))
assert_equal "This has a here.", strip_tags("This has a <!-- comment --> here.") assert_equal "This has a here.", strip_tags("This has a <!-- comment --> here.")
[nil, '', ' '].each { |blank| assert_nil strip_tags(blank) } [nil, '', ' '].each { |blank| assert_equal blank, strip_tags(blank) }
end end
end end

0 comments on commit 1d564d9

Please sign in to comment.