diff options
author | Rob Richards <rrichards@php.net> | 2008-09-10 16:28:53 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2008-09-10 16:28:53 +0000 |
commit | dcda8d83dd461b321808e1eb4ae2b19501692c67 (patch) | |
tree | 8ab9c1edd032344f3af2cec680f5717f707a657a /ext/simplexml | |
parent | e19c053adfcf22525ada61b25c35c6f24168ce19 (diff) | |
download | php-git-dcda8d83dd461b321808e1eb4ae2b19501692c67.tar.gz |
MFH: fix bug #46003 (isset on nonexisting node return unexpected results)
add test
Diffstat (limited to 'ext/simplexml')
-rw-r--r-- | ext/simplexml/simplexml.c | 2 | ||||
-rw-r--r-- | ext/simplexml/tests/bug46003.phpt | 30 |
2 files changed, 31 insertions, 1 deletions
diff --git a/ext/simplexml/simplexml.c b/ext/simplexml/simplexml.c index d8345a3626..546a9446e1 100644 --- a/ext/simplexml/simplexml.c +++ b/ext/simplexml/simplexml.c @@ -821,7 +821,7 @@ static int sxe_prop_dim_exists(zval *object, zval *member, int check_empty, zend while (node) { xmlNodePtr nnext; nnext = node->next; - if (!xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) { + if ((node->type == XML_ELEMENT_NODE) && !xmlStrcmp(node->name, (xmlChar *)Z_STRVAL_P(member))) { break; } node = nnext; diff --git a/ext/simplexml/tests/bug46003.phpt b/ext/simplexml/tests/bug46003.phpt new file mode 100644 index 0000000000..a10b018725 --- /dev/null +++ b/ext/simplexml/tests/bug46003.phpt @@ -0,0 +1,30 @@ +--TEST-- +Bug #46003 (isset on nonexisting nodes return unexpected results) +--FILE-- +<?php +$xml =<<<XML +<r> + <p>Test</p> + <o d='h'> + <xx rr='info' /> + <yy rr='data' /> + </o> +</r> +XML; + +$x = simplexml_load_string($xml); + +var_dump(isset($x->p)); +var_dump(isset($x->p->o)); +var_dump(isset($x->o->yy)); +var_dump(isset($x->o->zz)); +var_dump(isset($x->o->text)); +var_dump(isset($x->o->xx)); +?> +--EXPECTF-- +bool(true) +bool(false) +bool(true) +bool(false) +bool(false) +bool(true)
\ No newline at end of file |