[xml] bug with created attribute nodes?



Hello,

 It looks like there is a bug in libxml2 with handling pre-defined (or
numeric) entities while creating attribute nodes.
 Since i'm using libxml2 through PHP i can't give you proper testcase,
but maybe this one will also be useful for you:

<?php
$xml = domxml_open_mem('<'.'?xml version="1.0"?'.'><root/>');
$root = $xml->root();
$root->set_attribute('a','a&amp;b');
echo $xml->dump_mem();
?>

 This testcase produces following result:
<?xml version="1.0"?>
<root a="a&amp;#222;b"/>

 while it is expected to be:
<?xml version="1.0"?>
<root a="a&#222;b"/>

Internally set_attribute() method calls xmlSetProp() function which
seems to be buggy because it contains:

buffer = xmlEncodeEntitiesReentrant(node->doc, value);
prop->children = xmlStringGetNodeList(node->doc, buffer);

 As you may see - when you put pre-defined or numeric entity into
attribute - it is first quoted and only then parsed for entities and
it gives such behaviour. In other hand just loading such document in
libxml2 (for example through xmllint) gives correct output.

PS: I've tested it with libxml2 2.4.21 but there seems to be nothing in
ChangeLog about such thing.


-- 
Best regards,
 Alexander                          mailto:flying dom natm ru





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]