class Rails::HTML::Sanitizer

Constants

VERSION

Public Class Methods

best_supported_vendor() click to toggle source
# File lib/rails/html/sanitizer.rb, line 13
def best_supported_vendor
  html5_support? ? Rails::HTML5::Sanitizer : Rails::HTML4::Sanitizer
end
html5_support?() click to toggle source
# File lib/rails/html/sanitizer.rb, line 7
def html5_support?
  return @html5_support if defined?(@html5_support)

  @html5_support = Loofah.respond_to?(:html5_support?) && Loofah.html5_support?
end

Public Instance Methods

sanitize(html, options = {}) click to toggle source
# File lib/rails/html/sanitizer.rb, line 18
def sanitize(html, options = {})
  raise NotImplementedError, "subclasses must implement sanitize method."
end

Private Instance Methods

properly_encode(fragment, options) click to toggle source
# File lib/rails/html/sanitizer.rb, line 28
def properly_encode(fragment, options)
  fragment.xml? ? fragment.to_xml(options) : fragment.to_html(options)
end
remove_xpaths(node, xpaths) click to toggle source
# File lib/rails/html/sanitizer.rb, line 23
def remove_xpaths(node, xpaths)
  node.xpath(*xpaths).remove
  node
end