edge badge
Methods
P
S
T
V
Instance Public methods
sanitize(text, options = {})
# File actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb, line 7
def sanitize(text, options = {})
  validate_options(options)
  return text unless sanitizeable?(text)
  tokenize(text, options).join
end
sanitizeable?(text)
# File actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb, line 13
def sanitizeable?(text)
  !(text.nil? || text.empty? || !text.index("<"))
end
Instance Protected methods
process_node(node, result, options)
# File actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb, line 28
def process_node(node, result, options)
  result << node.to_s
end
tokenize(text, options)
# File actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb, line 18
def tokenize(text, options)
  tokenizer = HTML::Tokenizer.new(text)
  result = []
  while token = tokenizer.next
    node = Node.parse(nil, 0, 0, token, false)
    process_node node, result, options
  end
  result
end
validate_options(options)
# File actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb, line 32
def validate_options(options)
  if options[:tags] && !options[:tags].is_a?(Enumerable)
    raise ArgumentError, "You should pass :tags as an Enumerable"
  end

  if options[:attributes] && !options[:attributes].is_a?(Enumerable)
    raise ArgumentError, "You should pass :attributes as an Enumerable"
  end
end