diff options
author | Daniel Atallah <datallah@pidgin.im> | 2007-10-09 19:28:48 +0000 |
---|---|---|
committer | Daniel Atallah <datallah@pidgin.im> | 2007-10-09 19:28:48 +0000 |
commit | b9b58a5a6bfa4bdc56cc294665e13821aefc5e5b (patch) | |
tree | b0c64e0210ae9d3cb8f69af8901b7008b2c0708c | |
parent | a1ddd740d227d40bd8d8b16a2d255f67d9c1c132 (diff) | |
download | pidgin-b9b58a5a6bfa4bdc56cc294665e13821aefc5e5b.tar.gz |
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.
-rw-r--r-- | libpurple/protocols/bonjour/parser.c | 2 | ||||
-rw-r--r-- | libpurple/protocols/jabber/parser.c | 2 | ||||
-rw-r--r-- | libpurple/xmlnode.c | 20 |
3 files changed, 20 insertions, 4 deletions
diff --git a/libpurple/protocols/bonjour/parser.c b/libpurple/protocols/bonjour/parser.c index adc2d4621a..c062dce348 100644 --- a/libpurple/protocols/bonjour/parser.c +++ b/libpurple/protocols/bonjour/parser.c @@ -64,7 +64,7 @@ bonjour_parser_element_start_libxml(void *user_data, 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); diff --git a/libpurple/protocols/jabber/parser.c b/libpurple/protocols/jabber/parser.c index bd28f0f0d4..a6b65b0f04 100644 --- a/libpurple/protocols/jabber/parser.c +++ b/libpurple/protocols/jabber/parser.c @@ -80,7 +80,7 @@ jabber_parser_element_start_libxml(void *user_data, 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); diff --git a/libpurple/xmlnode.c b/libpurple/xmlnode.c index 9186dce96c..56890f5e56 100644 --- a/libpurple/xmlnode.c +++ b/libpurple/xmlnode.c @@ -146,6 +146,19 @@ xmlnode_remove_attrib(xmlnode *node, const char *attr) } } +/* 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(xmlnode *node, const char *attr, const char { 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(xmlnode *node, const char *attr, const char *x 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 xmlnode *parent, const char *name, const 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); |