]> granicus.if.org Git - php/commitdiff
- correct fix for bug #33059
authorRob Richards <rrichards@php.net>
Fri, 20 May 2005 15:01:38 +0000 (15:01 +0000)
committerRob Richards <rrichards@php.net>
Fri, 20 May 2005 15:01:38 +0000 (15:01 +0000)
- fix issue in other methods

ext/dom/element.c
ext/dom/node.c

index 9e23eee61a262203d66be1e5c465d17d51d67d84..09ba77df0c834d18d79b5f6d5bc414e72679d930 100644 (file)
@@ -250,7 +250,7 @@ PHP_FUNCTION(dom_element_set_attribute)
        }
 
        attr = xmlHasProp(nodep,name);
-       if (attr != NULL) {
+       if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) {
                node_list_unlink(attr->children TSRMLS_CC);
        }
        attr = xmlSetProp(nodep, name, value);
@@ -294,12 +294,14 @@ PHP_FUNCTION(dom_element_remove_attribute)
                RETURN_FALSE;
        }
 
-       /*      TODO: DTD defined attributes are handled special */
-       if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
-               node_list_unlink(attrp->children TSRMLS_CC);
-               xmlUnlinkNode((xmlNodePtr) attrp);
-       } else {
-               xmlUnlinkNode((xmlNodePtr) attrp);
+       if (attrp->type != XML_ATTRIBUTE_DECL) {
+               if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
+                       node_list_unlink(attrp->children TSRMLS_CC);
+                       xmlUnlinkNode((xmlNodePtr) attrp);
+                       xmlFreeProp(attrp);
+               } else {
+                       xmlUnlinkNode((xmlNodePtr) attrp);
+               }
        }
 
        RETURN_TRUE;
@@ -367,7 +369,7 @@ PHP_FUNCTION(dom_element_set_attribute_node)
        }
 
        existattrp = xmlHasProp(nodep, attrp->name);
-       if (existattrp != NULL) {
+       if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) {
                if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && 
                        ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp)
                {
@@ -539,7 +541,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
        if (errorcode == 0) {
                if (uri_len > 0) {
                        nodep = (xmlNodePtr) xmlHasNsProp(elemp, localname, uri);
-                       if (nodep != NULL) {
+                       if (nodep != NULL && nodep->type != XML_ATTRIBUTE_DECL) {
                                node_list_unlink(nodep->children TSRMLS_CC);
                        }
 
@@ -577,7 +579,7 @@ PHP_FUNCTION(dom_element_set_attribute_ns)
                        }
                } else {
                        attr = xmlHasProp(elemp, localname);
-                       if (attr != NULL) {
+                       if (attr != NULL && attr->type != XML_ATTRIBUTE_DECL) {
                                node_list_unlink(attr->children TSRMLS_CC);
                        }
                        attr = xmlSetProp(elemp, localname, value);
@@ -641,7 +643,7 @@ PHP_FUNCTION(dom_element_remove_attribute_ns)
                }
        }
 
-       if (attrp) {
+       if (attrp && attrp->type != XML_ATTRIBUTE_DECL) {
                if (php_dom_object_get_data((xmlNodePtr) attrp) == NULL) {
                        node_list_unlink(attrp->children TSRMLS_CC);
                        xmlUnlinkNode((xmlNodePtr) attrp);
@@ -725,7 +727,7 @@ PHP_FUNCTION(dom_element_set_attribute_node_ns)
         existattrp = xmlHasProp(nodep, attrp->name);
     }
 
-       if (existattrp != NULL) {
+       if (existattrp != NULL && existattrp->type != XML_ATTRIBUTE_DECL) {
                if ((oldobj = php_dom_object_get_data((xmlNodePtr) existattrp)) != NULL && 
                        ((php_libxml_node_ptr *)oldobj->ptr)->node == (xmlNodePtr) attrp)
                {
index 0fffde1b78e55db23403997385a8645028cc02a8..7de52e752916d6d91205759f671760192dfb3c0f 100644 (file)
@@ -992,7 +992,7 @@ PHP_FUNCTION(dom_node_insert_before)
                                lastattr = xmlHasProp(refp->parent, child->name);
                        else
                                lastattr = xmlHasNsProp(refp->parent, child->name, child->ns->href);
-                       if (lastattr != NULL) {
+                       if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
                                if (lastattr != (xmlAttrPtr) child) {
                                        xmlUnlinkNode((xmlNodePtr) lastattr);
                                        php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
@@ -1034,7 +1034,7 @@ PHP_FUNCTION(dom_node_insert_before)
                                lastattr = xmlHasProp(parentp, child->name);
                        else
                                lastattr = xmlHasNsProp(parentp, child->name, child->ns->href);
-                       if (lastattr != NULL) {
+                       if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
                                if (lastattr != (xmlAttrPtr) child) {
                                        xmlUnlinkNode((xmlNodePtr) lastattr);
                                        php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);
@@ -1286,7 +1286,7 @@ PHP_FUNCTION(dom_node_append_child)
                        lastattr = xmlHasProp(nodep, child->name);
                else
                        lastattr = xmlHasNsProp(nodep, child->name, child->ns->href);
-               if (lastattr != NULL) {
+               if (lastattr != NULL && lastattr->type != XML_ATTRIBUTE_DECL) {
                        if (lastattr != (xmlAttrPtr) child) {
                                xmlUnlinkNode((xmlNodePtr) lastattr);
                                php_libxml_node_free_resource((xmlNodePtr) lastattr TSRMLS_CC);