From 0a0d151bb8dd9c4a04befbaa302471860a530a94 Mon Sep 17 00:00:00 2001
From: Timm <kaspth@gmail.com>
Date: Fri, 13 Sep 2013 15:52:39 +0200
Subject: Now returning html if html is blank? in FullSanitizer and
 WhiteListSanitizer. This means it'll return false if called with false,
 however that is not a valid use case.

---
 actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb | 4 +++-
 actionview/test/template/sanitizers_test.rb                      | 8 ++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
index f6c13885ff..251820b81b 100644
--- a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
+++ b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb
@@ -1,4 +1,5 @@
 require 'active_support/core_ext/class/attribute'
+require 'active_support/core_ext/object/blank'
 require 'active_support/deprecation'
 require 'action_view/helpers/sanitize_helper/scrubbers'
 
@@ -25,7 +26,7 @@ module ActionView
   class FullSanitizer < Sanitizer
     def sanitize(html, options = {})
       return unless html
-      return html if html.empty?
+      return html if html.blank?
 
       Loofah.fragment(html).tap do |fragment|
         remove_xpaths(fragment, XPATHS_TO_REMOVE)
@@ -51,6 +52,7 @@ module ActionView
 
     def sanitize(html, options = {})
       return unless html
+      return html if html.blank?
 
       loofah_fragment = Loofah.fragment(html)
 
diff --git a/actionview/test/template/sanitizers_test.rb b/actionview/test/template/sanitizers_test.rb
index dc511b6ec2..48079bf060 100644
--- a/actionview/test/template/sanitizers_test.rb
+++ b/actionview/test/template/sanitizers_test.rb
@@ -98,7 +98,7 @@ class SanitizersTest < ActionController::TestCase
     assert_equal("This is a test.", sanitizer.sanitize("<p>This <u>is<u> a <a href='test.html'><strong>test</strong></a>.</p>"))
 
     assert_equal("", sanitizer.sanitize("<<<bad html>"))
-    
+
     assert_equal("This is a test.", sanitizer.sanitize("This is a test."))
 
     assert_equal "This has a  here.", sanitizer.sanitize("This has a <!-- comment --> here.")
@@ -219,7 +219,7 @@ class SanitizersTest < ActionController::TestCase
   def test_should_raise_argument_error_if_tags_is_not_enumerable
     sanitizer = ActionView::WhiteListSanitizer.new
     e = assert_raise(ArgumentError) do
-      sanitizer.sanitize('', :tags => 'foo')
+      sanitizer.sanitize('<a>some html</a>', :tags => 'foo')
     end
 
     assert_equal "You should pass :tags as an Enumerable", e.message
@@ -228,7 +228,7 @@ class SanitizersTest < ActionController::TestCase
   def test_should_raise_argument_error_if_attributes_is_not_enumerable
     sanitizer = ActionView::WhiteListSanitizer.new
     e = assert_raise(ArgumentError) do
-      sanitizer.sanitize('', :attributes => 'foo')
+      sanitizer.sanitize('<a>some html</a>', :attributes => 'foo')
     end
 
     assert_equal "You should pass :attributes as an Enumerable", e.message
@@ -242,7 +242,7 @@ class SanitizersTest < ActionController::TestCase
     end
 
     assert_raise Loofah::ScrubberNotFound do
-      sanitizer.sanitize('', :scrubber => scrubber)
+      sanitizer.sanitize('<a>some html</a>', :scrubber => scrubber)
     end
   end
 
-- 
cgit v1.2.3