From: Marcus Boerger Date: Mon, 24 Oct 2005 08:29:36 +0000 (+0000) Subject: - Fix issue with entities in attributes X-Git-Tag: php-5.1.0RC4~41 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5460d2dad6e90ace733b0efd909d2911d8c14aed;p=php - Fix issue with entities in attributes --- diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index e42ab2484e..19bb0fadec 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -689,10 +689,15 @@ sxe_properties_get(zval *object TSRMLS_DC) GET_NODE(sxe, node); node = php_sxe_get_first_node(sxe, node TSRMLS_CC); - - if (node) { - node = node->children; - + if (node && sxe->iter.type != SXE_ITER_ATTRLIST) { + if (node->type == XML_ATTRIBUTE_NODE) { + MAKE_STD_ZVAL(value); + ZVAL_STRING(value, xmlNodeListGetString(node->doc, node->children, 1), 1); + zend_hash_next_index_insert(rv, &value, sizeof(zval *), NULL); + node = NULL; + } else { + node = node->children; + } while (node) { if (node->children != NULL || node->prev != NULL || node->next != NULL) { SKIP_TEXT(node); diff --git a/ext/simplexml/tests/023.phpt b/ext/simplexml/tests/023.phpt new file mode 100755 index 0000000000..dd6dde59d7 --- /dev/null +++ b/ext/simplexml/tests/023.phpt @@ -0,0 +1,31 @@ +--TEST-- +SimpleXML: Attributes with entities +--SKIPIF-- + +--FILE-- + + + + +]> + +EOF; + +$sxe = simplexml_load_string($xml); + +var_dump($sxe); +var_dump($sxe['attr']); +?> +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (0) { +} +object(SimpleXMLElement)#%d (1) { + [0]=> + string(%d) "foo%sbar%sbaz" +} +===DONE===