This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: DOM tree inconsistency in expat XML parser
Type: behavior Stage: test needed
Components: XML Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, georg.brandl, inguin, loewis
Priority: normal Keywords: easy, patch

Created on 2006-02-18 11:10 by inguin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
python-2.4.2-expatbuilder.patch inguin, 2006-02-18 11:10 Patch for Python 2.4.2
Messages (3)
msg27571 - (view) Author: Ingo van Lil (inguin) Date: 2006-02-18 11:10
I wrote this to the xml-sig mailing list, but I didn't
receive any feedback. Maybe I'm heard here:
The expat XML parser module builds inconsistent DOM
trees if an XML file contains elements (e.g. a comment)
before the DOCTYPE declaration. The DocumentType node
is properly appended to the root node's children, but
neither its previousSibling pointer nor the previous
node's nextSibling pointer are set. E.g., when parsing
an XML file that looks like this:

<?xml version="1.0"?>
<!-- comment -->
<!DOCTYPE test SYSTEM "test.dtd">
<test> Hello world </test>

into a dom tree, the dom.childNodes vector will contain
three nodes (comment, document type and an element),
but the dom.firstChild.nextSibling points to 'None'.

The fix for this bug is trivial: The
start_doctype_decl_handler should not directly
manipulate the document's childNodes vector and use the
_append_child function instead. A patch against Python
2.4.2 is appended.
msg109770 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-09 16:49
A one line change against expatbuilder.py, could anyone with XML skills provide a unit test for this please?
msg109854 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-10 11:40
Fixed in r82761, thanks!
History
Date User Action Args
2022-04-11 14:56:15adminsetgithub: 42922
2010-07-10 11:40:19georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg109854

resolution: fixed
2010-07-09 16:49:16BreamoreBoysetnosy: + loewis, BreamoreBoy

messages: + msg109770
versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-03-21 00:25:37ajaksu2setkeywords: + patch, easy
stage: test needed
type: behavior
versions: + Python 2.6, - Python 2.4
2006-02-18 11:10:42inguincreate