class Rails::Html::FullSanitizer

Rails::Html::FullSanitizer

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

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

Public Instance Methods

sanitize(html, options = {}) click to toggle source
# File lib/rails/html/sanitizer.rb, line 25
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