diff options
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 |
