rrichards Wed, 05 May 2010 11:40:11 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=299016
Log:
fix bug #48601 (xpath() returns FALSE for legitimate query)
add test
Bug: http://bugs.php.net/48601 (Open) xpath() returns FALSE for legitimate query
Changed paths:
U php/php-src/branches/PHP_5_2/NEWS
U php/php-src/branches/PHP_5_2/ext/simplexml/simplexml.c
A php/php-src/branches/PHP_5_2/ext/simplexml/tests/bug48601.phpt
U php/php-src/branches/PHP_5_3/NEWS
U php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c
A php/php-src/branches/PHP_5_3/ext/simplexml/tests/bug48601.phpt
U php/php-src/trunk/ext/simplexml/simplexml.c
A php/php-src/trunk/ext/simplexml/tests/bug48601.phpt
Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS 2010-05-05 10:54:53 UTC (rev 299015)
+++ php/php-src/branches/PHP_5_2/NEWS 2010-05-05 11:40:11 UTC (rev 299016)
@@ -68,6 +68,7 @@
- Fixed bug #49723 (LimitIterator with empty SeekableIterator). (Etienne)
- Fixed bug #49576 (FILTER_VALIDATE_EMAIL filter needs updating) (Rasmus)
- Fixed bug #49267 (Linking fails for iconv). (Moriyosh)
+- Fixed bug #48601 (xpath() returns FALSE for legitimate query). (Rob)
- Fixed bug #48289 (iconv_mime_encode() quoted-printable scheme is broken).
(Adam, patch from hiroaki dot kawai at gmail dot com).
- Fixed bug #43314 (iconv_mime_encode(), broken Q scheme). (Rasmus)
Modified: php/php-src/branches/PHP_5_2/ext/simplexml/simplexml.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/simplexml/simplexml.c 2010-05-05 10:54:53 UTC (rev 299015)
+++ php/php-src/branches/PHP_5_2/ext/simplexml/simplexml.c 2010-05-05 11:40:11 UTC (rev 299016)
@@ -1219,31 +1219,29 @@
}
result = retval->nodesetval;
- if (!result) {
- xmlXPathFreeObject(retval);
- RETURN_FALSE;
- }
array_init(return_value);
- for (i = 0; i < result->nodeNr; ++i) {
- nodeptr = result->nodeTab[i];
- if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
- MAKE_STD_ZVAL(value);
- /**
- * Detect the case where the last selector is text(), simplexml
- * always accesses the text() child by default, therefore we assign
- * to the parent node.
- */
- if (nodeptr->type == XML_TEXT_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
- } else {
- _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- }
+ if (result != NULL) {
+ for (i = 0; i < result->nodeNr; ++i) {
+ nodeptr = result->nodeTab[i];
+ if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
+ MAKE_STD_ZVAL(value);
+ /**
+ * Detect the case where the last selector is text(), simplexml
+ * always accesses the text() child by default, therefore we assign
+ * to the parent node.
+ */
+ if (nodeptr->type == XML_TEXT_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
+ } else {
+ _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ }
- add_next_index_zval(return_value, value);
+ add_next_index_zval(return_value, value);
+ }
}
}
Added: php/php-src/branches/PHP_5_2/ext/simplexml/tests/bug48601.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/simplexml/tests/bug48601.phpt (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/simplexml/tests/bug48601.phpt 2010-05-05 11:40:11 UTC (rev 299016)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #48601 (xpath() returns FALSE for legitimate query)
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$sxe = simplexml_load_string('<root><node1>1</node1></root>');
+
+$nodes = $sxe->xpath("/root/node2/@test");
+
+if (! is_array($nodes)) {
+ echo "An error occured\n";
+} else {
+ echo "Result Count: " . count($nodes) . "\n";
+}
+
+?>
+--EXPECTF--
+Result Count: 0
Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS 2010-05-05 10:54:53 UTC (rev 299015)
+++ php/php-src/branches/PHP_5_3/NEWS 2010-05-05 11:40:11 UTC (rev 299016)
@@ -137,6 +137,7 @@
- Fixed bug #48983 (DomDocument : saveHTMLFile wrong charset). (Rob)
- Fixed bug #48902 (Timezone database fallback map is outdated). (Derick)
- Fixed bug #48781 (Cyclical garbage collector memory leak). (Dmitry)
+- Fixed bug #48601 (xpath() returns FALSE for legitimate query). (Rob)
- Fixed bug #48361 (SplFileInfo::getPathInfo should return the
parent dir). (Etienne)
- Fixed bug #48289 (iconv_mime_encode() quoted-printable scheme is broken).
Modified: php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c 2010-05-05 10:54:53 UTC (rev 299015)
+++ php/php-src/branches/PHP_5_3/ext/simplexml/simplexml.c 2010-05-05 11:40:11 UTC (rev 299016)
@@ -1258,31 +1258,29 @@
}
result = retval->nodesetval;
- if (!result) {
- xmlXPathFreeObject(retval);
- RETURN_FALSE;
- }
array_init(return_value);
- for (i = 0; i < result->nodeNr; ++i) {
- nodeptr = result->nodeTab[i];
- if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
- MAKE_STD_ZVAL(value);
- /**
- * Detect the case where the last selector is text(), simplexml
- * always accesses the text() child by default, therefore we assign
- * to the parent node.
- */
- if (nodeptr->type == XML_TEXT_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
- } else {
- _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- }
+ if (result != NULL) {
+ for (i = 0; i < result->nodeNr; ++i) {
+ nodeptr = result->nodeTab[i];
+ if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
+ MAKE_STD_ZVAL(value);
+ /**
+ * Detect the case where the last selector is text(), simplexml
+ * always accesses the text() child by default, therefore we assign
+ * to the parent node.
+ */
+ if (nodeptr->type == XML_TEXT_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
+ } else {
+ _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ }
- add_next_index_zval(return_value, value);
+ add_next_index_zval(return_value, value);
+ }
}
}
Added: php/php-src/branches/PHP_5_3/ext/simplexml/tests/bug48601.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/simplexml/tests/bug48601.phpt (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/simplexml/tests/bug48601.phpt 2010-05-05 11:40:11 UTC (rev 299016)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #48601 (xpath() returns FALSE for legitimate query)
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$sxe = simplexml_load_string('<root><node1>1</node1></root>');
+
+$nodes = $sxe->xpath("/root/node2/@test");
+
+if (! is_array($nodes)) {
+ echo "An error occured\n";
+} else {
+ echo "Result Count: " . count($nodes) . "\n";
+}
+
+?>
+--EXPECTF--
+Result Count: 0
Modified: php/php-src/trunk/ext/simplexml/simplexml.c
===================================================================
--- php/php-src/trunk/ext/simplexml/simplexml.c 2010-05-05 10:54:53 UTC (rev 299015)
+++ php/php-src/trunk/ext/simplexml/simplexml.c 2010-05-05 11:40:11 UTC (rev 299016)
@@ -1258,31 +1258,29 @@
}
result = retval->nodesetval;
- if (!result) {
- xmlXPathFreeObject(retval);
- RETURN_FALSE;
- }
array_init(return_value);
- for (i = 0; i < result->nodeNr; ++i) {
- nodeptr = result->nodeTab[i];
- if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
- MAKE_STD_ZVAL(value);
- /**
- * Detect the case where the last selector is text(), simplexml
- * always accesses the text() child by default, therefore we assign
- * to the parent node.
- */
- if (nodeptr->type == XML_TEXT_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
- _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
- } else {
- _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
- }
+ if (result != NULL) {
+ for (i = 0; i < result->nodeNr; ++i) {
+ nodeptr = result->nodeTab[i];
+ if (nodeptr->type == XML_TEXT_NODE || nodeptr->type == XML_ELEMENT_NODE || nodeptr->type == XML_ATTRIBUTE_NODE) {
+ MAKE_STD_ZVAL(value);
+ /**
+ * Detect the case where the last selector is text(), simplexml
+ * always accesses the text() child by default, therefore we assign
+ * to the parent node.
+ */
+ if (nodeptr->type == XML_TEXT_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ } else if (nodeptr->type == XML_ATTRIBUTE_NODE) {
+ _node_as_zval(sxe, nodeptr->parent, value, SXE_ITER_ATTRLIST, (char*)nodeptr->name, nodeptr->ns ? (xmlChar *)nodeptr->ns->href : NULL, 0 TSRMLS_CC);
+ } else {
+ _node_as_zval(sxe, nodeptr, value, SXE_ITER_NONE, NULL, NULL, 0 TSRMLS_CC);
+ }
- add_next_index_zval(return_value, value);
+ add_next_index_zval(return_value, value);
+ }
}
}
Added: php/php-src/trunk/ext/simplexml/tests/bug48601.phpt
===================================================================
--- php/php-src/trunk/ext/simplexml/tests/bug48601.phpt (rev 0)
+++ php/php-src/trunk/ext/simplexml/tests/bug48601.phpt 2010-05-05 11:40:11 UTC (rev 299016)
@@ -0,0 +1,20 @@
+--TEST--
+Bug #48601 (xpath() returns FALSE for legitimate query)
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$sxe = simplexml_load_string('<root><node1>1</node1></root>');
+
+$nodes = $sxe->xpath("/root/node2/@test");
+
+if (! is_array($nodes)) {
+ echo "An error occured\n";
+} else {
+ echo "Result Count: " . count($nodes) . "\n";
+}
+
+?>
+--EXPECTF--
+Result Count: 0
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php