im.pidgin.pidgin: 525a410c03e7e16535f3fe683f9651283109265d

datallah at pidgin.im datallah at pidgin.im
Tue Oct 9 15:35:38 EDT 2007


-----------------------------------------------------------------
Revision: 525a410c03e7e16535f3fe683f9651283109265d
Ancestor: 4d50bf3b08569aa2108a9f5da47fb1548d0c7dd9
Author: datallah at pidgin.im
Date: 2007-10-09T19:28:48
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/bonjour/parser.c
        libpurple/protocols/jabber/parser.c libpurple/xmlnode.c

ChangeLog: 

I think this is the correct fix for CID 319 and 321.  I added a note about two other cases where it appears that the xmlns isn't being compared correctly, but I'm afraid that fixing them will cause behavior change.

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/parser.c	d5decc6fae95d542db0e4f7c7d9c5d50240881e4
+++ libpurple/protocols/bonjour/parser.c	e0107a8afc655564ba4a1c424820b37e7d31dab4
@@ -64,7 +64,7 @@ bonjour_parser_element_start_libxml(void
 			char *attrib_ns = NULL;
 
 			if (attributes[i+2]) {
-				attrib_ns = g_strdup((char*)attributes[i+2]);;
+				attrib_ns = g_strdup((char*)attributes[i+2]);
 			}
 
 			memcpy(attrib, attributes[i+3], attrib_len);
============================================================
--- libpurple/protocols/jabber/parser.c	1b318b9d587444798232cf9664a84dae8b5b66af
+++ libpurple/protocols/jabber/parser.c	73f43838a4284923f4f621273894ee6f02654fd5
@@ -80,7 +80,7 @@ jabber_parser_element_start_libxml(void 
 			char *attrib_ns = NULL;
 
 			if (attributes[i+2]) {
-				attrib_ns = g_strdup((char*)attributes[i+2]);;
+				attrib_ns = g_strdup((char*)attributes[i+2]);
 			}
 
 			memcpy(attrib, attributes[i+3], attrib_len);
============================================================
--- libpurple/xmlnode.c	0a452bfe79ea0fea36de8bfe946cdb3097f066a5
+++ libpurple/xmlnode.c	301d2cff5e70a31ea398472724dbd6d27e73a3ea
@@ -146,7 +146,20 @@ xmlnode_remove_attrib(xmlnode *node, con
 	}
 }
 
+/* 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 @@ xmlnode_remove_attrib_with_namespace(xml
 	{
 		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 @@ xmlnode_get_attrib_with_namespace(xmlnod
 
 	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 @@ xmlnode_get_child_with_namespace(const x
 	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 @@ xmlnode_get_next_twin(xmlnode *node)
 	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);


More information about the Commits mailing list