[php-src] PR #12163: Fix bug #70570: json_encode and var_dump ignore simplexml cdata
| From: | nielsdos | Date: | Sat, 09 Sep 2023 19:03:06 +0000 |
| Subject: | [php-src] PR #12163: Fix bug #70570: json_encode and var_dump ignore simplexml cdata | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-23612@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/12163
Author: nielsdos
A sanity check for the behaviour would be nice :)
Sending to master because of potential BC break.
XML_CDATA_SECTION_NODE was simply not handled, handle it the same way as we handle text nodes for
consistency reasons.
We introduce the php_sxe_is_inclusive_text_node() helper for text-like nodes. In DOM parlance, these
2 types are called inclusive text nodes. Unfortunately, the fact that we handle CData the same as
text now has a technical BC break.
Previously this XML:
```xml
<?xml version="1.0" encoding="UTF-8"?>
<container>
<C><![CDATA[hello]]><foo/><![CDATA[world]]></C>
</container>
```
resulted in this var_dump output:
```
object(SimpleXMLElement)#1 (1) {
["C"]=>
object(SimpleXMLElement)#2 (1) {
["foo"]=>
object(SimpleXMLElement)#3 (0) {
}
}
}
```
However, after this patch (as text is not an element and thus handled specially) we get the
following output:
```
object(SimpleXMLElement)#1 (1) {
["C"]=>
string(10) "helloworld"
}
```