Changeset 147

Show
Ignore:
Timestamp:
06/04/2007 23:10:53 (18 months ago)
Author:
why
Message:
  • lib/hpricot/parse.rb: well well well. a bunch of tags and attrs weren't getting properly downcased by the html cleaner. thanks aaronp!
Location:
trunk
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/hpricot/parse.rb

    r146 r147  
    5151      Hpricot.scan(input) do |token| 
    5252        if stack.last[5] == :CDATA and ![:procins, :comment, :cdata].include?(token[0]) and 
    53             !(token[0] == :etag and token[1].send(conv) == stack.last[0]) 
     53            !(token[0] == :etag and token[1].casecmp(stack.last[0]).zero?) 
    5454          token[0] = :text 
    5555          token[1] = token[3] if token[3] 
    5656        end 
    5757 
    58         if token[0] == :emptytag and ElementContent[token[1].send(conv)] != :EMPTY and !opts[:xml] 
     58        if !opts[:xml] and token[0] == :emptytag and ElementContent[token[1].downcase] != :EMPTY 
    5959          token[0] = :stag 
     60        end 
     61 
     62        # TODO: downcase instead when parsing attributes? 
     63        if !opts[:xml] and token[2].is_a?(Hash) 
     64          token[2] = token[2].inject({}) { |hsh,(k,v)| hsh[k.downcase] = v; hsh } 
    6065        end 
    6166 
     
    6671          end 
    6772 
    68           stagname = token[0] = token[1].send(conv) 
     73          stagname = token[0] = token[1] = token[1].send(conv) 
    6974          if ElementContent[stagname] == :EMPTY and !opts[:xml] 
    7075            token[0] = :emptytag 
  • trunk/test/test_parser.rb

    r146 r147  
    174174  end 
    175175 
     176  def test_tag_case  
     177    @tenderlove = Hpricot.parse(TestFiles::TENDERLOVE)  
     178    assert_equal 2, @tenderlove.search('//a').length  
     179    assert_equal 2, @tenderlove.search('//area').length  
     180    assert_equal 2, @tenderlove.search('//meta').length  
     181  end  
     182 
    176183  def test_alt_predicates 
    177184    @boingboing = Hpricot.parse(TestFiles::BOINGBOING)