summaryrefslogtreecommitdiff
path: root/ext/dom/text.c
diff options
context:
space:
mode:
authorRob Richards <rrichards@php.net>2007-05-14 11:44:15 +0000
committerRob Richards <rrichards@php.net>2007-05-14 11:44:15 +0000
commitf42784219afaf622338ed03c6b9ad38e4139b687 (patch)
tree44455a645a8d3006755e7ba26b63861088d87f1e /ext/dom/text.c
parent725260ea0f083efaea66ba46ee32871804884a77 (diff)
downloadphp-git-f42784219afaf622338ed03c6b9ad38e4139b687.tar.gz
Fixed bug #41374 (wholetext concats values of wrong nodes).
add test
Diffstat (limited to 'ext/dom/text.c')
-rw-r--r--ext/dom/text.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/ext/dom/text.c b/ext/dom/text.c
index aaac4963b5..e0458fb328 100644
--- a/ext/dom/text.c
+++ b/ext/dom/text.c
@@ -87,7 +87,7 @@ Since: DOM Level 3
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 @@ int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC)
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);