Bugs: Browse | Submit New | Admin

[#6002] Feeding character entity reference 0187 will crash parser in 1.09

Date:
2006-10-03 09:15
Priority:
3
Submitted By:
Peter Krantz (peterkz)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
Feeding character entity reference 0187 will crash parser in 1.09

Detailed description
Parsing the following html:

<h1> &#0187;</h1>

will return this error in version 1.09:

ArgumentError: invalid value for Integer: "0187"
        from /opt/local/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/sgml-parser.rb:305:in `Integer'
        from /opt/local/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/sgml-parser.rb:305:in `handle_charref'
        from /opt/local/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/sgml-parser.rb:134:in `goahead'
        from /opt/local/lib/ruby/gems/1.8/gems/htmltools-1.09/lib/html/sgml-parser.rb:66:in `feed'

Add A Comment: Notepad

Please login


Followup

Message
Date: 2007-05-17 02:30
Sender: Daniel Hoey

I have also had trouble with this. The following should fix the
problem:

class HTML::SGMLParser
   alias_method :handle_charref_old, :handle_charref

   def handle_charref(name)
     handle_charref_old(name.gsub(/^0*/, ''))
   end
end

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item