[php-src] Issue #19189: Avoid libxml2's xmlNodeSetContent
| From: | nwellnhof | Date: | Sun, 20 Jul 2025 14:57:13 +0000 |
| Subject: | [php-src] Issue #19189: Avoid libxml2's xmlNodeSetContent | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-250460@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/19189
Author: nwellnhof
### Description
[xmlNodeSetContent](https://gnome.pages.gitlab.gnome.org/libxml2/html/tree_8h.html#adb743abd3a548d61e4a40df29c441e30)
decodes character and entity references which is typically not what users expect. This can be worked
around by first calling xmlNodeSetContent with a NULL pointer to clear the node and then using
xmlNodeAddContent which adds the string verbatim.
Here's an example:
```
<?php
$doc = new DOMDocument();
$doc->loadXML("<!DOCTYPE doc [ <!ENTITY e 'ent'>
]><doc/>");
$root = $doc->documentElement;
$root->nodeValue = "< &e; >";
echo($root->nodeValue); # prints "< ent >"
```
### PHP Version
```plain
All versions
```
### Operating System
_No response_