mirror of
https://github.com/github/rails.git
synced 2026-01-30 00:38:00 -05:00
strip_tags returns nil for a blank arg such as nil or "". Closes #2229.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4916 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* strip_tags returns nil for a blank arg such as nil or "". #2229 [duncan@whomwah.com]
|
||||
|
||||
* Cleanup assert_tag :children counting. #2181 [jamie@bravenet.com]
|
||||
|
||||
* button_to accepts :method so you can PUT and DELETE with it. #6005 [Dan Webb]
|
||||
|
||||
@@ -213,7 +213,8 @@ module ActionView
|
||||
# tokenizer and so it's HTML parsing ability is limited by that of html-scanner.
|
||||
#
|
||||
# Returns the tag free text.
|
||||
def strip_tags(html)
|
||||
def strip_tags(html)
|
||||
return nil if html.blank?
|
||||
if html.index("<")
|
||||
text = ""
|
||||
tokenizer = HTML::Tokenizer.new(html)
|
||||
|
||||
@@ -314,7 +314,7 @@ class TextHelperTest < Test::Unit::TestCase
|
||||
assert_equal(
|
||||
%{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}))
|
||||
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) }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user