1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00

MFH: fix bug #46047 (SimpleXML converts empty nodes into object with nested array)

add test
This commit is contained in:
Rob Richards
2008-09-11 14:21:33 +00:00
parent 94fd10cd79
commit dea7f49f70
2 changed files with 55 additions and 3 deletions
+7 -3
View File
@@ -1129,9 +1129,13 @@ static HashTable * sxe_get_prop_hash(zval *object, int is_debug TSRMLS_DC) /* {{
SKIP_TEXT(node);
} else {
if (node->type == XML_TEXT_NODE) {
MAKE_STD_ZVAL(value);
ZVAL_STRING(value, sxe_xmlNodeListGetString(node->doc, node, 1), 0);
zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL);
const xmlChar *cur = node->content;
if (*cur != 0) {
MAKE_STD_ZVAL(value);
ZVAL_STRING(value, sxe_xmlNodeListGetString(node->doc, node, 1), 0);
zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL);
}
goto next_iter;
}
}
+48
View File
@@ -0,0 +1,48 @@
--TEST--
Bug #46047 (SimpleXML converts empty nodes into object with nested array)
--FILE--
<?php
$xml = new SimpleXMLElement('<foo><bar><![CDATA[]]></bar><baz/></foo>',
LIBXML_NOCDATA);
print_r($xml);
$xml = new SimpleXMLElement('<foo><bar></bar><baz/></foo>');
print_r($xml);
$xml = new SimpleXMLElement('<foo><bar/><baz/></foo>');
print_r($xml);
?>
--EXPECTF--
SimpleXMLElement Object
(
[bar] => SimpleXMLElement Object
(
)
[baz] => SimpleXMLElement Object
(
)
)
SimpleXMLElement Object
(
[bar] => SimpleXMLElement Object
(
)
[baz] => SimpleXMLElement Object
(
)
)
SimpleXMLElement Object
(
[bar] => SimpleXMLElement Object
(
)
[baz] => SimpleXMLElement Object
(
)
)