|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23710 Handling of XML entites in set_content() is inconsistent
Submitted: 2003-05-20 04:05 UTC Modified: 2003-05-20 11:27 UTC
From: flying at dom dot natm dot ru Assigned:
Status: Wont fix Package: DOM XML related
PHP Version: 4.3.2RC3 OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: flying at dom dot natm dot ru
New email:
PHP Version: OS:


 [2003-05-20 04:05 UTC] flying at dom dot natm dot ru
set_content() handles XML entities differently, depending on context. Take a look at following example:

$xml = domxml_new_doc('1.0');
$root = $xml->append_child($xml->create_element('root'));
echo $xml->dumpmem();

It produces following document:

<?xml version="1.0"?>

 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)

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. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-05-20 11:27 UTC]
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.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 22 14:01:31 2024 UTC