diff options
Diffstat (limited to 'actionview/lib/action_view/helpers/sanitize_helper')
-rw-r--r-- | actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb index 99d4e64346..0e2e1826ec 100644 --- a/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb +++ b/actionview/lib/action_view/helpers/sanitize_helper/sanitizers.rb @@ -10,11 +10,12 @@ module ActionView end def remove_xpaths(html, xpaths) - html = Loofah.fragment(html) unless html.is_a? Nokogiri::XML::DocumentFragment - xpaths.each do |xpath| - html.xpath(xpath).each { |subtree| subtree.remove } + if html.respond_to?(:xpath) + xpaths.each { |xpath| html.xpath(xpath).remove } + html.to_s + else + remove_xpaths(Loofah.fragment(html), xpaths) end - html.to_s end end |