]> granicus.if.org Git - php/commitdiff
implement workaround for bug #38823 (DOMComment->appendData does nothing)
authorRob Richards <rrichards@php.net>
Sat, 16 Sep 2006 13:54:52 +0000 (13:54 +0000)
committerRob Richards <rrichards@php.net>
Sat, 16 Sep 2006 13:54:52 +0000 (13:54 +0000)
fix bug #38850 (lookupNamespaceURI doesn't return default namespace)
add test

ext/dom/characterdata.c
ext/dom/node.c
ext/dom/tests/bug38850.phpt [new file with mode: 0644]

index b45578e1e98c691a00f7311162812ecb4b3d4c32..3fe3e5bc99b65327a79cd8948f72a3f9243935f5 100644 (file)
@@ -207,9 +207,19 @@ PHP_FUNCTION(dom_characterdata_append_data)
        }
 
        DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
-
+#if LIBXML_VERSION < 20627
+/* Implement logic from libxml xmlTextConcat to add suport for comments and PI */
+    if ((nodep->content == (xmlChar *) &(nodep->properties)) ||
+        ((nodep->doc != NULL) && (nodep->doc->dict != NULL) &&
+               xmlDictOwns(nodep->doc->dict, nodep->content))) {
+       nodep->content = xmlStrncatNew(nodep->content, arg, arg_len);
+    } else {
+        nodep->content = xmlStrncat(nodep->content, arg, arg_len);
+    }
+    nodep->properties = NULL;
+#else
        xmlTextConcat(nodep, arg, arg_len);
-
+#endif
        RETURN_TRUE;
 }
 /* }}} end dom_characterdata_append_data */
index 2da7b438dec3785d2f1d9501f806347952a89bcb..849eebacfde602c9f522a0bb0181de7662c41c35 100644 (file)
@@ -1610,19 +1610,17 @@ PHP_FUNCTION(dom_node_lookup_namespace_uri)
        dom_object *intern;
        xmlNsPtr nsptr;
        int prefix_len = 0;
-       char *prefix;
+       char *prefix=NULL;
 
-       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os", &id, dom_node_class_entry, &prefix, &prefix_len) == FAILURE) {
+       if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os!", &id, dom_node_class_entry, &prefix, &prefix_len) == FAILURE) {
                return;
        }
 
        DOM_GET_OBJ(nodep, id, xmlNodePtr, intern);
 
-       if (prefix_len > 0) {
-               nsptr = xmlSearchNs(nodep->doc, nodep, prefix);
-               if (nsptr && nsptr->href != NULL) {
-                       RETURN_STRING((char *) nsptr->href, 1);
-               }
+       nsptr = xmlSearchNs(nodep->doc, nodep, prefix);
+       if (nsptr && nsptr->href != NULL) {
+               RETURN_STRING((char *) nsptr->href, 1);
        }
 
        RETURN_NULL();
diff --git a/ext/dom/tests/bug38850.phpt b/ext/dom/tests/bug38850.phpt
new file mode 100644 (file)
index 0000000..c8ca939
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+Bug # 38850 (lookupNamespaceURI does not return default namespace)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$xml = <<<HERE
+<?xml version="1.0" ?>
+<foo xmlns="http://www.example.com/ns/foo" />
+HERE;
+
+$doc = new DOMDocument();
+$doc->loadXML($xml);
+
+$root = $doc->documentElement;
+
+print $root->lookupNamespaceURI(NULL);
+
+
+?>
+--EXPECT--
+http://www.example.com/ns/foo