class Sanitize::Transformers::CSS::CleanAttribute

Enforces a CSS allowlist on the contents of ‘style` attributes.

def call(env)

def call(env)
  node = env[:node]
  return unless node.type == Nokogiri::XML::Node::ELEMENT_NODE &&
    node.key?("style") && !env[:is_allowlisted]
  attr = node.attribute("style")
  css = @scss.properties(attr.value)
  if css.strip.empty?
    attr.unlink
  else
    attr.value = css
  end
end

def initialize(sanitizer_or_config)

def initialize(sanitizer_or_config)
  @scss = if Sanitize::CSS === sanitizer_or_config
    sanitizer_or_config
  else
    Sanitize::CSS.new(sanitizer_or_config)
  end
end