class HTML::Pipeline::SanitizationFilter

HTML filter with sanization routines and whitelists. This module defines what HTML is allowed in user provided content and fixes up issues with unbalanced tags and whatnot.

See the Sanitize docs for more information on the underlying library:

github.com/rgrove/sanitize/#readme

Context options:

:whitelist - The sanitizer whitelist configuration to use. This can be one
             of the options constants defined in this class or a custom
             sanitize options hash.

This filter does not write additional information to the context.

Constants

FULL

Strip all HTML tags from the document.

LIMITED

A more limited sanitization whitelist. This includes all attributes, protocols, and transformers from WHITELIST but with a more locked down set of allowed elements.

WHITELIST

The main sanitization whitelist. Only these elements and attributes are allowed through by default.

Public Instance Methods

call() click to toggle source

Sanitize markup using the Sanitize library.

# File lib/html/pipeline/sanitization_filter.rb, line 60
def call
  Sanitize.clean_node!(doc, whitelist)
end
whitelist() click to toggle source

The whitelist to use when sanitizing. This can be passed in the context hash to the filter but defaults to WHITELIST constant value above.

# File lib/html/pipeline/sanitization_filter.rb, line 66
def whitelist
  context[:whitelist] || WHITELIST
end