Merge branch 'PHP-7.4' into PHP-8.0

* PHP-7.4:
  Revert "Fix #80852: Stack-overflow when json_encode()'ing SimpleXMLElement"
This commit is contained in:
Stanislav Malyshev 2021-04-26 21:02:09 -07:00
commit eed03fce59
No known key found for this signature in database
GPG Key ID: 94B3CB48C3ECA219
2 changed files with 2 additions and 23 deletions

View File

@ -1172,7 +1172,7 @@ static HashTable *sxe_get_prop_hash(zend_object *object, int is_debug) /* {{{ */
}
}
if (node->type == XML_ELEMENT_NODE && (! match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix)) || node->type == XML_ENTITY_DECL) {
if (node->type == XML_ELEMENT_NODE && (! match_ns(sxe, node, sxe->iter.nsprefix, sxe->iter.isprefix))) {
goto next_iter;
}
@ -1871,7 +1871,7 @@ static int sxe_object_cast_ex(zend_object *readobj, zval *writeobj, int type)
if (sxe->node && sxe->node->node) {
if (sxe->node->node->children) {
contents = xmlNodeListGetRawString((xmlDocPtr) sxe->document->ptr, sxe->node->node->children, 1);
contents = xmlNodeListGetString((xmlDocPtr) sxe->document->ptr, sxe->node->node->children, 1);
}
}
}

View File

@ -1,21 +0,0 @@
--TEST--
Bug #80852 (Stack-overflow when json_encode()'ing SimpleXMLElement)
--SKIPIF--
<?php
if (!extension_loaded('simplexml')) die('skip simplexml extension not available');
if (!extension_loaded('json')) die('skip json extension not available');
?>
--FILE--
<?php
$xml = '<!DOCTYPE foo [<!ENTITY xee1 "aaa"> <!ENTITY xee2 "&xee1;&xee1;"> ]><a>b&xee2;</a>';
$sxe = simplexml_load_string($xml);
var_dump(json_encode($sxe));
var_dump($sxe);
?>
--EXPECT--
string(11) "{"xee2":{}}"
object(SimpleXMLElement)#1 (1) {
["xee2"]=>
object(SimpleXMLElement)#3 (0) {
}
}