class Sanitize
def initialize(config = {})
def initialize(config = {}) # Sanitize configuration. @config = Config::DEFAULT.merge(config) @config[:transformers] = Array(@config[:transformers]) # :remove_contents takes precedence over :escape_only. if @config[:remove_contents] && @config[:escape_only] @config[:escape_only] = false end # Convert the list of allowed elements to a Hash for faster lookup. @allowed_elements = {} @config[:elements].each {|el| @allowed_elements[el] = true } # Specific nodes to whitelist (along with all their attributes). This array # is generated at runtime by transformers, and is cleared before and after # a fragment is cleaned (so it applies only to a specific fragment). @whitelist_nodes = [] end