pajoye                                   Wed, 03 Feb 2010 20:04:38 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=294446

Log:
- fix bug #49463 (setAttributeNS fails setting default namespace)

Bug: http://bugs.php.net/49463 (Closed) setAttributeNS fails setting default 
namespace
      
Changed paths:
    _U  php/php-src/branches/PHP_5_3_2/
    U   php/php-src/branches/PHP_5_3_2/ext/dom/element.c
    A + php/php-src/branches/PHP_5_3_2/ext/dom/tests/bug49463.phpt
        (from php/php-src/branches/PHP_5_3/ext/dom/tests/bug49463.phpt:r293597)
    _U  php/php-src/branches/PHP_5_3_2/ext/tidy/tests/
    _U  
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt


Property changes on: php/php-src/branches/PHP_5_3_2
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293268,293341,293380,293400,293442,293447,293466,293502,293538,293548,293558,293974
/php/php-src/trunk:284726
   + 
/php/php-src/branches/PHP_5_3:292504,292574,292594-292595,292611,292624,292630,292632-292635,292654,292677,292682-292683,292693,292719,292762,292765,292771,292777,292823,293051,293075,293114,293126,293131,293144,293146,293152,293176,293180,293216,293268,293341,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597,293974
/php/php-src/trunk:284726

Modified: php/php-src/branches/PHP_5_3_2/ext/dom/element.c
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/dom/element.c    2010-02-03 20:00:49 UTC 
(rev 294445)
+++ php/php-src/branches/PHP_5_3_2/ext/dom/element.c    2010-02-03 20:04:38 UTC 
(rev 294446)
@@ -777,9 +777,15 @@
                                node_list_unlink(nodep->children TSRMLS_CC);
                        }

-                       if (xmlStrEqual((xmlChar *) prefix, (xmlChar *)"xmlns") 
&& xmlStrEqual((xmlChar *) uri, (xmlChar *)DOM_XMLNS_NAMESPACE)) {
+                       if ((xmlStrEqual((xmlChar *) prefix, (xmlChar 
*)"xmlns") ||
+                               (prefix == NULL && xmlStrEqual((xmlChar *) 
localname, (xmlChar *)"xmlns"))) &&
+                               xmlStrEqual((xmlChar *) uri, (xmlChar 
*)DOM_XMLNS_NAMESPACE)) {
                                is_xmlns = 1;
-                               nsptr = dom_get_nsdecl(elemp, (xmlChar 
*)localname);
+                               if (prefix == NULL) {
+                                       nsptr = dom_get_nsdecl(elemp, NULL);
+                               } else {
+                                       nsptr = dom_get_nsdecl(elemp, (xmlChar 
*)localname);
+                               }
                        } else {
                                nsptr = xmlSearchNsByHref(elemp->doc, elemp, 
(xmlChar *)uri);
                                if (nsptr && nsptr->prefix == NULL) {
@@ -802,7 +808,12 @@

                        if (nsptr == NULL) {
                                if (prefix == NULL) {
-                                       errorcode = NAMESPACE_ERR;
+                                       if (is_xmlns == 1) {
+                                               xmlNewNs(elemp, (xmlChar 
*)value, NULL);
+                                               xmlReconciliateNs(elemp->doc, 
elemp);
+                                       } else {
+                                               errorcode = NAMESPACE_ERR;
+                                       }
                                } else {
                                        if (is_xmlns == 1) {
                                                xmlNewNs(elemp, (xmlChar 
*)value, (xmlChar *)localname);

Copied: php/php-src/branches/PHP_5_3_2/ext/dom/tests/bug49463.phpt (from rev 
293597, php/php-src/branches/PHP_5_3/ext/dom/tests/bug49463.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3_2/ext/dom/tests/bug49463.phpt                  
        (rev 0)
+++ php/php-src/branches/PHP_5_3_2/ext/dom/tests/bug49463.phpt  2010-02-03 
20:04:38 UTC (rev 294446)
@@ -0,0 +1,17 @@
+--TEST--
+Bug #49463 (setAttributeNS fails setting default namespace).
+--SKIPIF--
+<?php require_once('skipif.inc'); ?>
+--FILE--
+<?php
+
+$doc = new DOMDocument('1.0', 'utf-8');
+$root = $doc->createElementNS('http://purl.org/rss/1.0/','rdf:RDF');
+$doc->appendChild($root);
+$root->setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://purl.org/rss/1.0/";
 );
+
+echo $doc->saveXML()."\n";
+?>
+--EXPECT--
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF xmlns:rdf="http://purl.org/rss/1.0/"; 
xmlns="http://purl.org/rss/1.0/"/>


Property changes on: php/php-src/branches/PHP_5_3_2/ext/tidy/tests
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292719,292765,293146,293152,293176,293180,293216,293380,293400,293442,293447,293466,293502,293538,293548,293558
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941
   + 
/php/php-src/branches/PHP_5_3/ext/tidy/tests:292562,292566,292571,292574,292635,292719,292765,293146,293152,293176,293180,293216,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597
/php/php-src/trunk/ext/tidy/tests:284726,287798-287941


Property changes on: 
php/php-src/branches/PHP_5_3_2/tests/security/open_basedir_parse_ini_file.phpt
___________________________________________________________________
Modified: svn:mergeinfo
   - 
/php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,293146,293152,293176,293180,293216,293380,293400,293442,293447,293466,293502,293538,293548,293558
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951
   + 
/php/php-src/branches/PHP_5_3/tests/security/open_basedir_parse_ini_file.phpt:292562,292566,292571,292574,293146,293152,293176,293180,293216,293380,293400,293442,293447,293466,293502,293538,293548,293558,293597
/php/php-src/trunk/tests/security/open_basedir_parse_ini_file.phpt:265951

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

Reply via email to