#23710 [Opn->WFx]: Handling of XML entites in set_content() is inconsistent
| From: | chregu@php.net | Date: | Tue, 20 May 2003 16:27:03 +0000 |
| Subject: | #23710 [Opn->WFx]: Handling of XML entites in set_content() is inconsistent | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-40065@lists.php.net to get a copy of this message | ||
ID: 23710
Updated by: chregu@php.net
Reported By: flying at dom dot natm dot ru
-Status: Open
+Status: Wont fix
Bug Type: DOM XML related
Operating System: All
PHP Version: 4.3.2RC3
New Comment:
set_content is buggy as hell, if you use it twice...
my advice. use it only once or use the proper DOM methods
(create_text_node and append_child).
I won't fix it, since domxml support will be phased out in PHP5 and
we're currently focusing on a new, much better dom-and-xml-in-general
extension.
chregu
Previous Comments:
------------------------------------------------------------------------
[2003-05-20 04:05:34] flying at dom dot natm dot ru
set_content() handles XML entities differently, depending on context.
Take a look at following example:
<?php
$xml = domxml_new_doc('1.0');
$root = $xml->append_child($xml->create_element('root'));
$root->set_content(' ');
$root->set_content(' ');
echo $xml->dumpmem();
?>
It produces following document:
<?xml version="1.0"?>
<root> &#160;</root>
Note, that first entity was determined as entity, but second - as
plain text, and hence quoted. Problem is in php_domxml.c, function
domxml_node_set_content(), around line 2734 (as for version)
1.218.2.23:
if (nodep->children) {
xmlNodeAddContentLen(nodep, content, content_len);
} else {
xmlNodeSetContentLen(nodep, content, content_len);
}
If you'll take a look into source of these functions in libxml (file
tree.c) - you will see, that xmlNodeSetContentLen() parses given
content for entities, while xmlNodeAddContentLen() - not.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=23710&edit=1