diff options
author | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:48 -0400 |
---|---|---|
committer | Mark A. Hershberger <mah@debian.(none)> | 2009-03-25 00:37:48 -0400 |
commit | eddbbea4325e602ddc87c545531609132d4f0e3b (patch) | |
tree | f0994206a7e0a6251be7cc6729ba480f0c8729c2 /ext/dom | |
parent | 2d4e5b09576bb4f0ba716cc82cdf29ea04d9184b (diff) | |
download | php-eddbbea4325e602ddc87c545531609132d4f0e3b.tar.gz |
Imported Upstream version 5.2.3upstream/5.2.3
Diffstat (limited to 'ext/dom')
-rw-r--r-- | ext/dom/element.c | 3 | ||||
-rw-r--r-- | ext/dom/node.c | 13 | ||||
-rw-r--r-- | ext/dom/tests/bug36756.phpt | 2 | ||||
-rw-r--r-- | ext/dom/tests/bug41257.phpt | 31 | ||||
-rw-r--r-- | ext/dom/tests/bug41374.phpt | 32 | ||||
-rw-r--r-- | ext/dom/text.c | 25 |
6 files changed, 96 insertions, 10 deletions
diff --git a/ext/dom/element.c b/ext/dom/element.c index c31338d81..4d9303f50 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: element.c,v 1.36.2.4.2.7 2007/01/01 09:36:00 sebastian Exp $ */ +/* $Id: element.c,v 1.36.2.4.2.8 2007/05/04 19:30:59 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -709,6 +709,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns) } else { nsptr = dom_get_ns(elemp, uri, &errorcode, prefix); } + xmlReconciliateNs(elemp->doc, elemp); } } else { if (is_xmlns == 1) { diff --git a/ext/dom/node.c b/ext/dom/node.c index 256235ee9..ce04c182f 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: node.c,v 1.37.2.3.2.7 2007/03/18 21:31:04 rrichards Exp $ */ +/* $Id: node.c,v 1.37.2.3.2.8 2007/05/04 19:30:59 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -1586,8 +1586,11 @@ PHP_FUNCTION(dom_node_is_default_namespace) } DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); + if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { + nodep = xmlDocGetRootElement((xmlDocPtr) nodep); + } - if (uri_len > 0) { + if (nodep && uri_len > 0) { nsptr = xmlSearchNs(nodep->doc, nodep, NULL); if (nsptr && xmlStrEqual(nsptr->href, uri)) { RETURN_TRUE; @@ -1617,6 +1620,12 @@ PHP_FUNCTION(dom_node_lookup_namespace_uri) } DOM_GET_OBJ(nodep, id, xmlNodePtr, intern); + if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) { + nodep = xmlDocGetRootElement((xmlDocPtr) nodep); + if (nodep == NULL) { + RETURN_NULL(); + } + } nsptr = xmlSearchNs(nodep->doc, nodep, prefix); if (nsptr && nsptr->href != NULL) { diff --git a/ext/dom/tests/bug36756.phpt b/ext/dom/tests/bug36756.phpt index e24f9f080..af7488d3f 100644 --- a/ext/dom/tests/bug36756.phpt +++ b/ext/dom/tests/bug36756.phpt @@ -1,5 +1,5 @@ --TEST-- -Bug #36756: (DOMDocument::removeChild corrupts node) +Bug #36756 (DOMDocument::removeChild corrupts node) --SKIPIF-- <?php require_once('skipif.inc'); ?> --FILE-- diff --git a/ext/dom/tests/bug41257.phpt b/ext/dom/tests/bug41257.phpt new file mode 100644 index 000000000..58e6acfd5 --- /dev/null +++ b/ext/dom/tests/bug41257.phpt @@ -0,0 +1,31 @@ +--TEST-- +Bug # 41257: (lookupNamespaceURI does not work as expected) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php + +$doc = new DOMDocument(); +$doc->load(dirname(__FILE__)."/nsdoc.xml"); + +$root = $doc->documentElement; + +$duri = $doc->lookupNamespaceURI("ns2")."\n"; +$euri = $root->lookupNamespaceURI("ns2")."\n"; + +var_dump($duri == $euri); + +$dpref = $doc->lookupPrefix("http://ns2")."\n"; +$epref = $root->lookupPrefix("http://ns2")."\n"; + +var_dump($dpref == $epref); + +$disdef = $doc->isDefaultNamespace("http://ns")."\n"; +$eisdef = $root->isDefaultNamespace("http://ns")."\n"; + +var_dump($dpref === $epref); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) diff --git a/ext/dom/tests/bug41374.phpt b/ext/dom/tests/bug41374.phpt new file mode 100644 index 000000000..6de5ffbc0 --- /dev/null +++ b/ext/dom/tests/bug41374.phpt @@ -0,0 +1,32 @@ +--TEST-- +Bug # 41374: (wholetext concats values of wrong nodes) +--SKIPIF-- +<?php require_once('skipif.inc'); ?> +--FILE-- +<?php +$xml = (binary)<<<EOXML +<?xml version="1.0" encoding="ISO-8859-1" ?> +<root>foo<child />baz</root> +EOXML; + +$doc = new DOMDocument(); +$doc->loadXML($xml); + +$root = $doc->documentElement; +$foo = $root->firstChild; + +var_dump($foo->wholeText == "foo"); + +$bar = $root->insertBefore($doc->createTextNode("bar"), $foo->nextSibling); + +var_dump($foo->wholeText == "foobar"); +var_dump($foo->wholeText == $bar->wholeText); +$baz = $bar->nextSibling->nextSibling; + +var_dump($baz->wholeText === $foo->wholeText); +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(false) diff --git a/ext/dom/text.c b/ext/dom/text.c index 3a03c7516..6cc47bdda 100644 --- a/ext/dom/text.c +++ b/ext/dom/text.c @@ -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.4 2007/05/14 11:52:35 rrichards Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -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,11 +96,24 @@ int dom_text_whole_text_read(dom_object *obj, zval **retval TSRMLS_DC) return FAILURE; } - ALLOC_ZVAL(*retval); - wholetext = xmlNodeListGetString(node->doc, node, 1); - ZVAL_STRING(*retval, wholetext, 1); + /* 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; + } - xmlFree(wholetext); + ALLOC_ZVAL(*retval); + if (wholetext != NULL) { + ZVAL_STRING(*retval, wholetext, 1); + xmlFree(wholetext); + } else { + ZVAL_EMPTY_STRING(*retval); + } return SUCCESS; } |