[Python-bugs-list] bugs in xmllib (PR#146)

dgudeman@azstarnet.com dgudeman@azstarnet.com
Fri, 3 Dec 1999 18:11:14 -0500 (EST)


Full_Name: Dave Gudeman
Version: 1.52
OS: all (only verified on Windows 95)
Submission from: dialup19ip095.tus.azstarnet.com (169.197.39.95)


Please send email to confirm that you received this...

I have found 2.5 bugs in xmllib.py and am contributing a patch for 1.5 of them.

Bug #1 (fixed in patch): handle_entityref() is never called.

Bug #1.5 (addressed in patch): handle_entityref() doesn't handle the built-in
named character refs correctly. It passes them on to handle_data() as an
unresolved charref. This is half a bug because it isn't a bug until you
apply the patch to fix #1. Also, whoever maintains xmllib may not like
my fix for this one because I just skip the call to handle_charref(). I don't
think it should be called in this case, but reasonable people may differ.

Bug #2: The documentation states that handle_doctype() takes two arguments
but it really takes 4. I think the correct solution to this is to fix the doc,
not the function.

Sorry, my windows diff will not produce context diffs, but this is pretty
trivial:
333,340c333
<                     if self.entitydefs.has_key(name):
<                         self.rawdata = rawdata = rawdata[:res.start(0)] +
self.entitydefs[name] + rawdata[i:]
<                         n = len(rawdata)
<                         i = res.start(0)
<                     else:
<                         self.syntax_error("reference to unknown entity `&%s;'"
% name)
<                         self.unknown_entityref(name)
<                     self.lineno = self.lineno + string.count(res.group(0),
'\n')
---
>                     self.handle_entityref(name)
706,710c707,711
<     entitydefs = {'lt': '&#60;',        # must use charref
<                   'gt': '&#62;',
<                   'amp': '&#38;',       # must use charref
<                   'quot': '&#34;',
<                   'apos': '&#39;',
---
>     entitydefs = {'lt': '<',        # must use charref
>                   'gt': '>',
>                   'amp': '&',       # must use charref
>                   'quot': '"',
>                   'apos': "'",


I confirm that, to the best of my knowledge and belief, this
contribution is free of any claims of third parties under
copyright, patent or other rights or interests ("claims").  To
the extent that I have any such claims, I hereby grant to CNRI a
nonexclusive, irrevocable, royalty-free, worldwide license to
reproduce, distribute, perform and/or display publicly, prepare
derivative versions, and otherwise use this contribution as part
of the Python software and its related documentation, or any
derivative versions thereof, at no cost to CNRI or its licensed
users, and to authorize others to do so.

I acknowledge that CNRI may, at its sole discretion, decide
whether or not to incorporate this contribution in the Python
software and its related documentation.  I further grant CNRI
permission to use my name and other identifying information
provided to CNRI by me for use in connection with the Python
software and its related documentation.