diff --git a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb index f6c13885ff8617df4f84e696694da91fb25d64cc..251820b81b873d1845705c15b4697d5a161be93c 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 @@ def remove_xpaths(html, xpaths) 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 @@ def initialize 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 dc511b6ec26c05158a53863e1b8978fb19c649b9..48079bf0600e3693684781c589c9f7f9eb9766a1 100644 --- a/actionview/test/template/sanitizers_test.rb +++ b/actionview/test/template/sanitizers_test.rb @@ -98,7 +98,7 @@ def test_strip_tags assert_equal("This is a test.", sanitizer.sanitize("
This is a test.
")) assert_equal("", sanitizer.sanitize("<<