# class HTML::Sanitizer

### Public Instance Methods

sanitize(text, options = {}) click to toggle source

    # File lib/rails/deprecated_sanitizer/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) click to toggle source

    # File lib/rails/deprecated_sanitizer/html-scanner/html/sanitizer.rb, line 13
    def sanitizeable?(text)
      !(text.nil? || text.empty? || !text.index("<"))
    end

### Protected Instance Methods

process_node(node, result, options) click to toggle source

    # File lib/rails/deprecated_sanitizer/html-scanner/html/sanitizer.rb, line 28
    def process_node(node, result, options)
      result << node.to_s
    end

tokenize(text, options) click to toggle source

    # File lib/rails/deprecated_sanitizer/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) click to toggle source

    # File lib/rails/deprecated_sanitizer/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