rrichards               Thu Mar 20 16:48:45 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/simplexml/tests        bug44478.phpt 

  Modified files:              
    /php-src/ext/simplexml      simplexml.c 
  Log:
  MFH: fix bug #44478 (Inconsistent behaviour when assigning new nodes)
  add test
  
http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/simplexml.c?r1=1.151.2.22.2.38&r2=1.151.2.22.2.39&diff_format=u
Index: php-src/ext/simplexml/simplexml.c
diff -u php-src/ext/simplexml/simplexml.c:1.151.2.22.2.38 
php-src/ext/simplexml/simplexml.c:1.151.2.22.2.39
--- php-src/ext/simplexml/simplexml.c:1.151.2.22.2.38   Thu Jan 31 21:59:41 2008
+++ php-src/ext/simplexml/simplexml.c   Thu Mar 20 16:48:45 2008
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: simplexml.c,v 1.151.2.22.2.38 2008/01/31 21:59:41 rrichards Exp $ */
+/* $Id: simplexml.c,v 1.151.2.22.2.39 2008/03/20 16:48:45 rrichards Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -422,19 +422,12 @@
                        convert_to_string(value);
                        /* break missing intentionally */
                case IS_STRING:
-                       if (node->type == XML_ATTRIBUTE_NODE) {
-                               buffer = xmlEncodeEntitiesReentrant(node->doc, 
(xmlChar *)Z_STRVAL_P(value));
-                               buffer_len = xmlStrlen(buffer);
-                       } else {
-                               buffer = (xmlChar *)Z_STRVAL_P(value);
-                               buffer_len = Z_STRLEN_P(value);
-                       }
+                       buffer = xmlEncodeEntitiesReentrant(node->doc, (xmlChar 
*)Z_STRVAL_P(value));
+                       buffer_len = xmlStrlen(buffer);
                        /* check for NULL buffer in case of memory error in 
xmlEncodeEntitiesReentrant */
                        if (buffer) {
                                xmlNodeSetContentLen(node, buffer, buffer_len);
-                               if (node->type == XML_ATTRIBUTE_NODE) {
-                                       xmlFree(buffer);
-                               }
+                               xmlFree(buffer);
                        }
                        if (value == &value_copy) {
                                zval_dtor(value);
@@ -2452,7 +2445,7 @@
 {
        php_info_print_table_start();
        php_info_print_table_header(2, "Simplexml support", "enabled");
-       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.38 $");
+       php_info_print_table_row(2, "Revision", "$Revision: 1.151.2.22.2.39 $");
        php_info_print_table_row(2, "Schema support",
 #ifdef LIBXML_SCHEMAS_ENABLED
                "enabled");

http://cvs.php.net/viewvc.cgi/php-src/ext/simplexml/tests/bug44478.phpt?view=markup&rev=1.1
Index: php-src/ext/simplexml/tests/bug44478.phpt
+++ php-src/ext/simplexml/tests/bug44478.phpt
--TEST--
Bug #44478 (Inconsistent behaviour when assigning new nodes)
--FILE--
<?php
$xml_element = new simpleXMLElement('<root></root>');
$xml_element->node1 = 'a &#38; b';
print $xml_element->node1."\n";
$xml_element->node1 = 'a &#38; b';
print $xml_element->node1."\n";
$xml_element->addChild('node2','a &#38; b');
print $xml_element->node2."\n";
$xml_element->node2 = 'a & b';
print $xml_element->node2."\n";

print $xml_element->asXML();

?>
--EXPECTF--
a &#38; b
a &#38; b
a & b
a & b
<?xml version="1.0"?>
<root><node1>a &amp;#38; b</node1><node2>a &amp; b</node2></root>



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to