Bugs: Browse | Submit New | Admin

[#9664] invalid value for Integer: "038" throws exception

Date:
2007-03-29 10:44
Priority:
3
Submitted By:
erik van eykelen (evaneykelen)
Assigned To:
Nobody (None)
Category:
None
State:
Open
Summary:
invalid value for Integer: "038" throws exception

Detailed description
Parsing this file (http://feedparser.org/docs/examples/atom03.xml) throws an exception because it contains text like
'Laptops & Notebooks' ('Laptops space ampersand hash zero three eight space Notebooks).

The culprit is this code in sgml-parser.rb:

def handle_charref(name)
  n = Integer(name)
  if !(0 <= n && n <= 255)
    unknown_charref(name)
    return
  end
  handle_data(n.chr)
end

A simple fix would be to say n = name.to_i. Note that the Integer method honors leading radix indicators like 0, 0b
and 0x, thereby making to_i a better suited conversion method.

Add A Comment: Notepad

Please login


Followup

No Followups Have Been Posted

Attached Files:

Name Description Download
No Files Currently Attached

Changes:

No Changes Have Been Made to This Item