]> granicus.if.org Git - php/commitdiff
Fix #70029: nodeValue of DOMElement list content of children nodes
authorChristoph M. Becker <cmbecker69@gmx.de>
Fri, 10 Jul 2015 11:42:09 +0000 (13:42 +0200)
committerChristoph M. Becker <cmb@php.net>
Fri, 4 Sep 2015 23:52:41 +0000 (01:52 +0200)
According to the W3C DOM Core Level 3 specification DOMElement::nodeValue is
supposed to yield null, but currently the DOM extension yield the result of
calling xmlNodeGetContent(), what is the concatenation of the values of the
children of the element. This patch fixes the non standard behavior.

ext/dom/node.c
ext/dom/tests/bug28721.phpt
ext/dom/tests/bug42082.phpt
ext/dom/tests/bug69846.phpt
ext/dom/tests/bug70029.phpt [new file with mode: 0644]
ext/dom/tests/dom001.phpt

index 2f35e0110b1ab47dad6a63ef3e47341c95a77bba..08e4332a06ad44cf2041dacd867a971847f5140f 100644 (file)
@@ -297,7 +297,6 @@ int dom_node_node_value_read(dom_object *obj, zval *retval)
        switch (nodep->type) {
                case XML_ATTRIBUTE_NODE:
                case XML_TEXT_NODE:
-               case XML_ELEMENT_NODE:
                case XML_COMMENT_NODE:
                case XML_CDATA_SECTION_NODE:
                case XML_PI_NODE:
index 464498ef808a02c384f5cd4ab4f845a1505f0e4e..cd55150087935899dc3d7f0793d42c3f0f62175d 100644 (file)
@@ -119,66 +119,65 @@ print_node_r($p);
 
 ?>
 --EXPECT--
-
-name (value): p ( t1 X t2  xxx )
+name (value): p ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
   name (value): #text ( t1 )
-  parent: name (value): p ( t1 X t2  xxx )
+  parent: name (value): p ()
   previousSibling: NULL
-  nextSibling: name (value): b (X)
+  nextSibling: name (value): b ()
 
-  name (value): b (X)
-  parent: name (value): p ( t1 X t2  xxx )
+  name (value): b ()
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t1 )
   nextSibling: name (value): #text ( t2 )
 
     name (value): #text (X)
-    parent: name (value): b (X)
+    parent: name (value): b ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t2 )
-  parent: name (value): p ( t1 X t2  xxx )
-  previousSibling: name (value): b (X)
+  parent: name (value): p ()
+  previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): p ( t1 X t2  xxx )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t2 )
   nextSibling: NULL
 
 Append t1 to p:
 
-name (value): p (X t2  xxx  t1 )
+name (value): p ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
-  name (value): b (X)
-  parent: name (value): p (X t2  xxx  t1 )
+  name (value): b ()
+  parent: name (value): p ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t2 )
 
     name (value): #text (X)
-    parent: name (value): b (X)
+    parent: name (value): b ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t2 )
-  parent: name (value): p (X t2  xxx  t1 )
-  previousSibling: name (value): b (X)
+  parent: name (value): p ()
+  previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): p (X t2  xxx  t1 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t2 )
   nextSibling: name (value): #text ( t1 )
 
   name (value): #text ( t1 )
-  parent: name (value): p (X t2  xxx  t1 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( xxx )
   nextSibling: NULL
 
@@ -186,18 +185,18 @@ t1 == ret: bool(true)
 
 div:
 
-name (value): div ( t3  t4  xxx )
+name (value): div ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
   name (value): #text ( t3 )
-  parent: name (value): div ( t3  t4  xxx )
+  parent: name (value): div ()
   previousSibling: NULL
   nextSibling: name (value): b ()
 
   name (value): b ()
-  parent: name (value): div ( t3  t4  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t3 )
   nextSibling: name (value): #text ( t4 )
 
@@ -207,34 +206,34 @@ nextSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t4 )
-  parent: name (value): div ( t3  t4  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): div ( t3  t4  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t4 )
   nextSibling: NULL
 
 Insert t4 before t3:
 
-name (value): div ( t4  t3  xxx )
+name (value): div ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
   name (value): #text ( t4 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t3 )
 
   name (value): #text ( t3 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t4 )
   nextSibling: name (value): b ()
 
   name (value): b ()
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t3 )
   nextSibling: name (value): #text ( xxx )
 
@@ -244,40 +243,40 @@ nextSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( xxx )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): b ()
   nextSibling: NULL
 
 
 p:
 
-name (value): p (X t2  xxx  t1 )
+name (value): p ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
-  name (value): b (X)
-  parent: name (value): p (X t2  xxx  t1 )
+  name (value): b ()
+  parent: name (value): p ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t2 )
 
     name (value): #text (X)
-    parent: name (value): b (X)
+    parent: name (value): b ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t2 )
-  parent: name (value): p (X t2  xxx  t1 )
-  previousSibling: name (value): b (X)
+  parent: name (value): p ()
+  previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): p (X t2  xxx  t1 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t2 )
   nextSibling: name (value): #text ( t1 )
 
   name (value): #text ( t1 )
-  parent: name (value): p (X t2  xxx  t1 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( xxx )
   nextSibling: NULL
 
@@ -291,73 +290,73 @@ nextSibling: NULL
   name (value): #text ( t5 )
   parent: name (value): #document-fragment ()
   previousSibling: NULL
-  nextSibling: name (value): i ( frob )
+  nextSibling: name (value): i ()
 
-  name (value): i ( frob )
+  name (value): i ()
   parent: name (value): #document-fragment ()
   previousSibling: name (value): #text ( t5 )
   nextSibling: name (value): #text ( t6 )
 
     name (value): #text ( frob )
-    parent: name (value): i ( frob )
+    parent: name (value): i ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t6 )
   parent: name (value): #document-fragment ()
-  previousSibling: name (value): i ( frob )
+  previousSibling: name (value): i ()
   nextSibling: NULL
 
 Appending fragment to p:
 
-name (value): p (X t2  xxx  t1  t5  frob  t6 )
+name (value): p ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
-  name (value): b (X)
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  name (value): b ()
+  parent: name (value): p ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t2 )
 
     name (value): #text (X)
-    parent: name (value): b (X)
+    parent: name (value): b ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t2 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
-  previousSibling: name (value): b (X)
+  parent: name (value): p ()
+  previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t2 )
   nextSibling: name (value): #text ( t1 )
 
   name (value): #text ( t1 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( xxx )
   nextSibling: name (value): #text ( t5 )
 
   name (value): #text ( t5 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t1 )
-  nextSibling: name (value): i ( frob )
+  nextSibling: name (value): i ()
 
-  name (value): i ( frob )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  name (value): i ()
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t5 )
   nextSibling: name (value): #text ( t6 )
 
     name (value): #text ( frob )
-    parent: name (value): i ( frob )
+    parent: name (value): i ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t6 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
-  previousSibling: name (value): i ( frob )
+  parent: name (value): p ()
+  previousSibling: name (value): i ()
   nextSibling: NULL
 
 Fragment:
@@ -369,23 +368,23 @@ nextSibling: NULL
 
 div:
 
-name (value): div ( t4  t3  xxx )
+name (value): div ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
   name (value): #text ( t4 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t3 )
 
   name (value): #text ( t3 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t4 )
   nextSibling: name (value): b ()
 
   name (value): b ()
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t3 )
   nextSibling: name (value): #text ( xxx )
 
@@ -395,30 +394,30 @@ nextSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( xxx )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): b ()
   nextSibling: NULL
 
 Inserting fragment before t4
 Error (2) on line 109: DOMNode::insertBefore(): Document Fragment is empty
 
-name (value): div ( t4  t3  xxx )
+name (value): div ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
   name (value): #text ( t4 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t3 )
 
   name (value): #text ( t3 )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t4 )
   nextSibling: name (value): b ()
 
   name (value): b ()
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): #text ( t3 )
   nextSibling: name (value): #text ( xxx )
 
@@ -428,58 +427,58 @@ nextSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( xxx )
-  parent: name (value): div ( t4  t3  xxx )
+  parent: name (value): div ()
   previousSibling: name (value): b ()
   nextSibling: NULL
 
 p:
 
-name (value): p (X t2  xxx  t1  t5  frob  t6 )
+name (value): p ()
 parent: NULL
 previousSibling: NULL
 nextSibling: NULL
 
-  name (value): b (X)
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  name (value): b ()
+  parent: name (value): p ()
   previousSibling: NULL
   nextSibling: name (value): #text ( t2 )
 
     name (value): #text (X)
-    parent: name (value): b (X)
+    parent: name (value): b ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t2 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
-  previousSibling: name (value): b (X)
+  parent: name (value): p ()
+  previousSibling: name (value): b ()
   nextSibling: name (value): #text ( xxx )
 
   name (value): #text ( xxx )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t2 )
   nextSibling: name (value): #text ( t1 )
 
   name (value): #text ( t1 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( xxx )
   nextSibling: name (value): #text ( t5 )
 
   name (value): #text ( t5 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t1 )
-  nextSibling: name (value): i ( frob )
+  nextSibling: name (value): i ()
 
-  name (value): i ( frob )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
+  name (value): i ()
+  parent: name (value): p ()
   previousSibling: name (value): #text ( t5 )
   nextSibling: name (value): #text ( t6 )
 
     name (value): #text ( frob )
-    parent: name (value): i ( frob )
+    parent: name (value): i ()
     previousSibling: NULL
     nextSibling: NULL
 
   name (value): #text ( t6 )
-  parent: name (value): p (X t2  xxx  t1  t5  frob  t6 )
-  previousSibling: name (value): i ( frob )
+  parent: name (value): p ()
+  previousSibling: name (value): i ()
   nextSibling: NULL
index b5fc8931636a8ec3a8d46d53176a72b38979a97d..98fa638ba5a2efa10cb66c7819bdf68459095cf6 100644 (file)
@@ -22,10 +22,10 @@ DOMNodeList
 int(0)
 bool(true)
 bool(true)
-string(0) ""
-bool(true)
+NULL
 bool(true)
 bool(false)
 bool(false)
+bool(false)
 ===DONE===
        
index 08e35cdcf6b8573b40af1d52c73ffd9b6cfbce7f..a667a897d560f59d86b3455ee1110b491c651c52 100644 (file)
@@ -81,11 +81,7 @@ object(DOMElement)#%d (17) {
   ["nodeName"]=>
   string(5) "form1"
   ["nodeValue"]=>
-  string(39) "
-    Value A
-    Value B
-    Value C
-  "
+  NULL
   ["nodeType"]=>
   int(1)
   ["parentNode"]=>
diff --git a/ext/dom/tests/bug70029.phpt b/ext/dom/tests/bug70029.phpt
new file mode 100644 (file)
index 0000000..55244c6
--- /dev/null
@@ -0,0 +1,12 @@
+--TEST--
+Bug #70029 (nodeValue of DOMElement list content of children nodes)
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+$doc = new DOMDocument();
+$doc->loadXml('<tag><childtag>myString</childtag></tag>');
+var_dump($doc->documentElement->nodeValue);
+?>
+--EXPECT--
+NULL
index a0c78fbb0a19f839d92cedf22f92af8a4c049e60..13e8fbf76fa4dc7e132fc97923bf79ba7edde847 100644 (file)
@@ -108,7 +108,7 @@ Num Children: 4
 Node Name: title
 Node Type: 1
 Num Children: 1
-Node Content: Title
+Node Content: 
 
 Node Name: #text
 Node Type: 3
@@ -142,7 +142,7 @@ Num Children: 4
 Node Name: title
 Node Type: 1
 Num Children: 1
-Node Content: Title
+Node Content: 
 
 Node Name: #text
 Node Type: 3
@@ -186,7 +186,7 @@ Node Content: en
 Node Name: Silly
 Node Type: 1
 Num Children: 1
-Node Content: Symphony
+Node Content: 
 
 <?xml version="1.0" standalone="yes"?>
 <!DOCTYPE chapter SYSTEM "/share/sgml/Norman_Walsh/db3xml10/db3xml10.dtd" [
@@ -214,24 +214,24 @@ Node Content: Symphony
 Node Name: Silly
 Node Type: 1
 Num Children: 1
-Node Content: Symphony
+Node Content: 
 
     Using elem
 Node Name: Silly
 Node Type: 1
 Num Children: 1
-Node Content: Symphony
+Node Content: 
 
 --------- Unlink Node
 Node Name: Silly
 Node Type: 1
 Num Children: 1
-Node Content: Symphony
+Node Content: 
 
 Node Name: title
 Node Type: 1
 Num Children: 1
-Node Content: Title
+Node Content: 
 
 Node Name: #text
 Node Type: 3