diff options
author | Marcus Boerger <helly@php.net> | 2005-10-24 08:29:36 +0000 |
---|---|---|
committer | Marcus Boerger <helly@php.net> | 2005-10-24 08:29:36 +0000 |
commit | 5460d2dad6e90ace733b0efd909d2911d8c14aed (patch) | |
tree | f2673463ce43d2814d85bb6388ce2936fef3e870 | |
parent | a0dd931d85adc648b001c6beb6671a90d4406c4a (diff) | |
download | php-git-5460d2dad6e90ace733b0efd909d2911d8c14aed.tar.gz |
- Fix issue with entities in attributes
-rw-r--r-- | ext/simplexml/simplexml.c | 13 | ||||
-rwxr-xr-x | ext/simplexml/tests/023.phpt | 31 |
2 files changed, 40 insertions, 4 deletions
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-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<!DOCTYPE talks SYSTEM "nbsp.dtd" [ +<!ELEMENT root EMPTY> +<!ATTLIST root attr1 CDATA #IMPLIED> +<!ENTITY nbsp "&#x00A0;"> +]> +<root attr='foo bar baz'></root> +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=== |