diff options
author | Rob Richards <rrichards@php.net> | 2005-05-20 15:01:38 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2005-05-20 15:01:38 +0000 |
commit | 022461d976658bc55c44b5db4132aaad592d7546 (patch) | |
tree | 10edb29924ef1d56fa042651119b33a9dc93e480 | |
parent | 4ce95ef1eaa6bca3255cd481346a25071928612b (diff) | |
download | php-git-022461d976658bc55c44b5db4132aaad592d7546.tar.gz |
- correct fix for bug #33059
- fix issue in other methods
-rw-r--r-- | ext/dom/element.c | 26 | ||||
-rw-r--r-- | ext/dom/node.c | 6 |
2 files changed, 17 insertions, 15 deletions
diff --git a/ext/dom/element.c b/ext/dom/element.c index 9e23eee61a..09ba77df0c 100644 --- a/ext/dom/element.c +++ b/ext/dom/element.c @@ -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) { diff --git a/ext/dom/node.c b/ext/dom/node.c index 0fffde1b78..7de52e7529 100644 --- a/ext/dom/node.c +++ b/ext/dom/node.c @@ -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); |