After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 333522 - Error message for malformed internal parsed entities
Error message for malformed internal parsed entities
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.x
Other Linux
: Normal enhancement
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2006-03-05 19:58 UTC by Mathias Hasselmann (IRC: tbf)
Modified: 2007-06-12 12:20 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
libxml2-2.6.23-bug-333522.patch (981 bytes, patch)
2006-03-05 21:27 UTC, Mathias Hasselmann (IRC: tbf)
none Details | Review

Description Mathias Hasselmann (IRC: tbf) 2006-03-05 19:58:18 UTC
Quote from http://www.w3.org/TR/2004/REC-xml-20040204/#wf-entities:

    An internal general parsed entity is well-formed if
    its replacement text matches the production labeled 
    content. All internal parameter entities are well-
    formed by definition.

Appears like libxml2, release 2.6.23 doesn't reflect this paragraph:

<?xml version="1.0"?>

<!DOCTYPE root [
 <!ELEMENT root (#PCDATA|child)*> 
 <!ELEMENT child (#PCDATA)*> 
 <!ENTITY a "<child>"> 
 <!ENTITY b "</child>">
]> 

<root>&a;test&b;</root>

When executing "xmllint -valid --noout" you get:

Entity: line 1: parser error : Premature end of data in tag child line 1
<child>
       ^
test.xml:10: parser error : Unregistered error message
<root>&a;test&b;</root>
         ^
The first error message is misleading as it doesn't properly point to the problematic location: Instead of "Entity: line 1" it should read "test.xml: Line 6". Guess the second error message reveals another internal bug in libxml2?
Comment 1 Daniel Veillard 2006-03-05 20:23:57 UTC
libxml2 handling is right. Entities must be pushed on the stack to detect that
kind of errors, for example the following is well-formed:

<?xml version="1.0"?>

<!DOCTYPE root [
 <!ELEMENT root (#PCDATA|child)*> 
 <!ELEMENT child (#PCDATA)*> 
 <!ENTITY a "<child>"> 
 <!ENTITY b "</child>">
]> 

<root>test</root>

And entity can have multiple line, so you get
the line number where it occured in it. At best for entities defined
in the internal subset the name of the entity could be reported but that
would require to augment the amount of data used for entities pushed on
the stack at runtime. Doesn't look a serious problem.
The second message precisely allow to tell where in the entity stack 
the error occured, you get the full context for all pushed entities.

Daniel
Comment 2 Mathias Hasselmann (IRC: tbf) 2006-03-05 21:27:42 UTC
Created attachment 60715 [details] [review]
libxml2-2.6.23-bug-333522.patch

Fixes the "Unregistered error message" problem and eject an additional error message "Referencing malformed entity. See previous error message for details" at the cost of being verbose and generating two error messages when referencing the malformed entity.
Comment 3 Mathias Hasselmann (IRC: tbf) 2007-02-02 02:17:42 UTC
I accept libxml's behaviour being correct regarding XML handling. Nevertheless the patch should be applied as it makes sense to improve the error reporting here to save other users of libxml some time.
Comment 4 Daniel Veillard 2007-06-12 12:20:39 UTC
Current error message is:

paphio:~/XML -> xmllint test.xml
Entity: line 1: parser error : Premature end of data in tag child line 1
<child>
       ^
test.xml:10: parser error : Entity 'a' failed to parse
<root>&a;test&b;</root>
         ^
paphio:~/XML -> 

I think it is sufficient, at least there is no unregistered error raised.

Daniel