class Arachni::Parser::SAX
Attributes
document[R]
Public Class Methods
new( options = {} )
click to toggle source
Calls superclass method
# File lib/arachni/parser/sax.rb, line 20 def initialize( options = {} ) super() @document = Document.new @stop_on_first = Set.new @stop_on_first.merge( options[:stop_on_first] ) if options[:stop_on_first] @current_node = @document end
Public Instance Methods
attr( name, value )
click to toggle source
# File lib/arachni/parser/sax.rb, line 51 def attr( name, value ) return if !@current_node.respond_to?( :attributes ) @current_node.attributes[name] = value end
comment( value )
click to toggle source
# File lib/arachni/parser/sax.rb, line 62 def comment( value ) @current_node << Nodes::Comment.new( value ) end
end_element( name )
click to toggle source
# File lib/arachni/parser/sax.rb, line 44 def end_element( name ) # Finished parsing the desired element, abort. fail Stop if @stop @current_node = @current_node.parent end
start_element( name )
click to toggle source
# File lib/arachni/parser/sax.rb, line 31 def start_element( name ) # We were instructed to stop on the first sight of the previous element # but came across this one before it closed. fail Stop if @stop @stop = stop?( name ) e = Nodes::Element.new( name ) e.document = @document @current_node << e @current_node = e end
text( value )
click to toggle source
# File lib/arachni/parser/sax.rb, line 57 def text( value ) return if value.strip.empty? @current_node << Nodes::Text.new( value ) end
Private Instance Methods
stop?( name )
click to toggle source
# File lib/arachni/parser/sax.rb, line 68 def stop?( name ) return false if @stop_on_first.empty? @stop_on_first.include?( name.to_s.downcase ) end