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 322136 - In xmlNodeBufGetContent: element node's child entity reference nodes are expanded incorrectly
In xmlNodeBufGetContent: element node's child entity reference nodes are expa...
Status: RESOLVED FIXED
Product: libxml2
Classification: Platform
Component: general
2.6.22
Other All
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2005-11-22 14:27 UTC by Oleksandr Kononenko
Modified: 2005-12-20 16:06 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Oleksandr Kononenko 2005-11-22 14:27:07 UTC
Parse document with entity reference in element contents.
xmlNodeBufGetContent(el) returns NULL instead of entity value.
        //-----------------------------------------------
        xmlNodePtr el = xmlDocGetRootElement(doc);
        xmlNodePtr ref = el->children; // entity reference here 
        xmlChar* r1 = xmlNodeGetContent(el);
        xmlChar* r2 = xmlNodeGetContent(ref);
        // r1 is NULL (if there is only one child),  r2 is the contents of the 
entity reference

XML file used:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE xmluiml SYSTEM "file:///c:/tmp/DTDFile.dtd">
<xmluiml>&hello;</xmluiml>

with DTDFile.dtd:
<!ENTITY hello "Hello">


Explanation:

For element node its children are iterated and for entity reference there is a 
recursive call for getting value for _children_ of the entity reference. On the 
other hand, in the case when function is called for entity reference node, an 
entity node is retrieved by name and function is recursively called for _entity 
node's_ children list. 

How to fix:

Replace in xmlNodeBufGetContent within switch's XML_ELEMENT_NODE branch:
                        ...
                        case XML_ENTITY_REF_NODE:
                            xmlNodeBufGetContent(buffer, tmp->children);
                            break;
                        ...
with
                        case XML_ENTITY_REF_NODE:
                            xmlNodeBufGetContent(buffer, tmp);
                            break;

Function will be recursively called for XML_ENTITY_REF_NODE and same processing 
(the correct one) will be held for getting content from the entity reference.
Comment 1 Rob Richards 2005-12-20 16:06:22 UTC
Thanks, fixed in CVS