Class: Html::FullSanitizer

Inherits:
Sanitizer show all
Defined in:
lib/html/sanitizer/sanitizer.rb

Overview

Html::FullSanitizer

Removes all tags but strips out scripts, forms and comments.

full_sanitizer = Html::FullSanitizer.new full_sanitizer.sanitize(“Bold no more! <a href=‘more.html’>See more here</a>…”) # => Bold no more! See more here…

Constant Summary

Constants inherited from Sanitizer

Sanitizer::VERSION

Instance Method Summary collapse

Methods inherited from Sanitizer

full_sanitizer, link_sanitizer, white_list_sanitizer

Instance Method Details

#sanitize(html, options = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/html/sanitizer/sanitizer.rb', line 24

def sanitize(html, options = {})
  return unless html
  return html if html.empty?

  Loofah.fragment(html).tap do |fragment|
    remove_xpaths(fragment, XPATHS_TO_REMOVE)
  end.text
end