rrichards Mon May 14 11:44:15 2007 UTC
Added files: (Branch: PHP_5_2)
/php-src/ext/dom/tests bug41374.phpt
Modified files:
/php-src/ext/dom text.c
Log:
Fixed bug #41374 (wholetext concats values of wrong nodes).
add test
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/text.c?r1=1.23.2.1.2.2&r2=1.23.2.1.2.3&diff_format=u
Index: php-src/ext/dom/text.c
diff -u php-src/ext/dom/text.c:1.23.2.1.2.2 php-src/ext/dom/text.c:1.23.2.1.2.3
--- php-src/ext/dom/text.c:1.23.2.1.2.2 Mon Jan 1 09:36:00 2007
+++ php-src/ext/dom/text.c Mon May 14 11:44:15 2007
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: text.c,v 1.23.2.1.2.2 2007/01/01 09:36:00 sebastian Exp $ */
+/* $Id: text.c,v 1.23.2.1.2.3 2007/05/14 11:44:15 rrichards Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -87,7 +87,7 @@
int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC)
{
xmlNodePtr node;
- xmlChar *wholetext;
+ xmlChar *wholetext = NULL;
node = dom_object_get_node(obj);
@@ -96,9 +96,23 @@
return FAILURE;
}
+ /* Find starting text node */
+ while (node->prev && ((node->prev->type == XML_TEXT_NODE) ||
(node->prev->type == XML_CDATA_SECTION_NODE))) {
+ node = node->prev;
+ }
+
+ /* concatenate all adjacent text and cdata nodes */
+ while (node && ((node->type == XML_TEXT_NODE) || (node->type ==
XML_CDATA_SECTION_NODE))) {
+ wholetext = xmlStrcat(wholetext, node->content);
+ node = node->next;
+ }
+
ALLOC_ZVAL(*retval);
- wholetext = xmlNodeListGetString(node->doc, node, 1);
- ZVAL_STRING(*retval, wholetext, 1);
+ if (wholetext != NULL) {
+ ZVAL_STRING(*retval, wholetext, 1);
+ } else {
+ ZVAL_EMPTY_STRING(*retval);
+ }
xmlFree(wholetext);
http://cvs.php.net/viewvc.cgi/php-src/ext/dom/tests/bug41374.phpt?view=markup&rev=1.1
Index: php-src/ext/dom/tests/bug41374.phpt
+++ php-src/ext/dom/tests/bug41374.phpt
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php