diff libpurple/xmlnode.c @ 20332:3a9709bfde65

applied changes from 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9 through 525a410c03e7e16535f3fe683f9651283109265d applied changes from 525a410c03e7e16535f3fe683f9651283109265d through d4b316d73ebaf93803ca2642e78b8821c3b5d5c7
author Luke Schierer <lschiere@pidgin.im>
date Fri, 19 Oct 2007 18:27:12 +0000
parents 6b8bc3309ab7
children b93e7be3847b
line wrap: on
line diff
--- a/libpurple/xmlnode.c	Fri Oct 19 18:24:58 2007 +0000
+++ b/libpurple/xmlnode.c	Fri Oct 19 18:27:12 2007 +0000
@@ -146,6 +146,19 @@
 	}
 }
 
+/* Compare two nullable xmlns strings.
+ * They are considered equal if they're both NULL or the strings are equal
+ */
+static gboolean _xmlnode_compare_xmlns(const char *xmlns1, const char *xmlns2) {
+	gboolean equal = FALSE;
+
+	if (xmlns1 == NULL && xmlns2 == NULL)
+		equal = TRUE;
+	else if (xmlns1 != NULL && xmlns2 != NULL && !strcmp(xmlns1, xmlns2))
+		equal = TRUE;
+
+	return equal;
+}
 
 void
 xmlnode_remove_attrib_with_namespace(xmlnode *node, const char *attr, const char *xmlns)
@@ -159,7 +172,7 @@
 	{
 		if(attr_node->type == XMLNODE_TYPE_ATTRIB &&
 		   !strcmp(attr_node->name, attr) &&
-		   !strcmp(attr_node->xmlns, xmlns))
+		   _xmlnode_compare_xmlns(xmlns, attr_node->xmlns))
 		{
 			if(node->child == attr_node) {
 				node->child = attr_node->next;
@@ -238,7 +251,8 @@
 
 	for(x = node->child; x; x = x->next) {
 		if(x->type == XMLNODE_TYPE_ATTRIB &&
-		   !strcmp(attr, x->name) && !strcmp(x->xmlns, xmlns)) {
+		   !strcmp(attr, x->name) &&
+		   _xmlnode_compare_xmlns(xmlns, x->xmlns)) {
 			return x->data;
 		}
 	}
@@ -326,6 +340,7 @@
 	child_name = names[1];
 
 	for(x = parent->child; x; x = x->next) {
+		/* XXX: Is it correct to ignore the namespace for the match if none was specified? */
 		const char *xmlns = NULL;
 		if(ns)
 			xmlns = xmlnode_get_namespace(x);
@@ -673,6 +688,7 @@
 	g_return_val_if_fail(node->type == XMLNODE_TYPE_TAG, NULL);
 
 	for(sibling = node->next; sibling; sibling = sibling->next) {
+		/* XXX: Is it correct to ignore the namespace for the match if none was specified? */
 		const char *xmlns = NULL;
 		if(ns)
 			xmlns = xmlnode_get_namespace(sibling);