class Rails::HTML::Sanitizer

Constants

VERSION

Public Class Methods

allowed_uri?(uri_string) click to toggle source
# File lib/rails/html/sanitizer.rb, line 17
def allowed_uri?(uri_string)
  Loofah::HTML5::Scrub.allowed_uri?(uri_string)
end
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 22
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 32
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 27
def remove_xpaths(node, xpaths)
  node.xpath(*xpaths).remove
  node
end