classification
Title: xmlrpclib loads invalid documents
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: effbot, exarkun, georg.brandl, rhettinger
Priority: normal Keywords: patch

Created on 2009-04-16 00:19 by exarkun, last changed 2012-05-24 13:23 by amaury.forgeotdarc. This issue is now closed.

Files
File name Uploaded Description Edit
xmlrpclib.patch exarkun, 2009-05-20 18:23
Messages (6)
msg86010 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-04-16 00:19
Prior versions of xmlrpclib.loads would raise an exception when passed
malformed documents:

exarkun@bigdog24:~/_trial_temp$ python2.4 -c 'from xmlrpclib import
loads; loads("\x00\n<methodResponse>\n <params>\n  <param>\n  </param>\n
</params>\n</methodResponse>\n")'
Traceback (most recent call last):
  File "<string>", line 1, in ?
  File "/usr/lib/python2.4/xmlrpclib.py", line 1079, in loads
    p.feed(data)
  File "/usr/lib/python2.4/xmlrpclib.py", line 527, in feed
    self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: not well-formed (invalid token): line 2,
column 0

However, as of the most recent Python 2.5 and Python 2.6 point releases,
this is no longer the case:

exarkun@bigdog24:~/_trial_temp$ python2.5 -c 'from xmlrpclib import
loads; loads("\x00\n<methodResponse>\n <params>\n  <param>\n  </param>\n
</params>\n</methodResponse>\n")'
exarkun@bigdog24:~/_trial_temp$ python2.6 -c 'from xmlrpclib import
loads; loads("\x00\n<methodResponse>\n <params>\n  <param>\n  </param>\n
</params>\n</methodResponse>\n")'
exarkun@bigdog24:~/_trial_temp$

Previous versions of Python 2.5 and Python 2.6 did not exhibit this
misbehavior.
msg86033 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-04-16 15:40
This actually appears to be an issue with the sgmlop-based parser, not
the expat-based parser.  After removing sgmlop, the exception-raising
behavior is restored.

Perhaps this bug should be closed as invalid, then.  Only, I wonder if
this is the right bug tracker to use for sgmlop, or if it has one
somewhere else?
msg86034 - (view) Author: Fredrik Lundh (effbot) * (Python committer) Date: 2009-04-16 15:51
sgmlop doesn't do much validation; to quote the homepage: "[sgmlop] is 
tolerant, and happily accepts XML-like data that are not well-formed. If 
you need strictness, use another parser."

But given that Python ships with cElementTree these days, and 
cElementTree's XMLParser (based on expat) is faster than both sgmlop and 
pyexpat, maybe it's time to remove sgmlop support from xmlrpclib...
msg86036 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-04-16 16:56
> maybe it's time to remove sgmlop support from xmlrpclib...

+1
msg88127 - (view) Author: Jean-Paul Calderone (exarkun) * (Python committer) Date: 2009-05-20 18:23
Here's a patch which removes sgmlop support from xmlrpclib.
msg88868 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-06-04 09:01
Applied in r73201, r73202.
History
Date User Action Args
2012-05-24 13:23:48amaury.forgeotdarcsettitle: xmlrpclib expat -> xmlrpclib loads invalid documents
2012-05-24 08:58:00Phil.Daintreesetversions: + Python 2.7, - Python 2.6, Python 2.5
title: xmlrpclib loads invalid documents -> xmlrpclib expat
2009-06-04 09:01:29georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg88868

resolution: accepted
2009-05-20 18:23:09exarkunsetfiles: + xmlrpclib.patch
keywords: + patch
messages: + msg88127
2009-04-16 16:56:14rhettingersetnosy: + rhettinger
messages: + msg86036
2009-04-16 15:51:25effbotsetmessages: + msg86034
2009-04-16 15:40:35exarkunsetnosy: + effbot
messages: + msg86033
2009-04-16 00:19:55exarkuncreate