aboutsummaryrefslogtreecommitdiffstats
path: root/lib/xmltree.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2010-06-06 00:21:02 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2010-06-06 00:21:02 +0100
commitb308cf9bafbdf76da73a57607b65c4763aa3057b (patch)
treec686906b479a0edd52b18a213e1d420f7343855d /lib/xmltree.c
parent3ab1d317831a6c1830bb648a1a8d63a41c92f651 (diff)
parente774815bc621af90bb64ca314b84367659c5a005 (diff)
Merging libpurple branch into killerbee. It's fairly usable already, and
Debian packaging is now properly separated. This also picks up a load of stuff from mainline it seems.
Diffstat (limited to 'lib/xmltree.c')
-rw-r--r--lib/xmltree.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c
index 67fe46e1..31f8ee9c 100644
--- a/lib/xmltree.c
+++ b/lib/xmltree.c
@@ -448,7 +448,11 @@ struct xt_node *xt_find_node( struct xt_node *node, const char *name )
{
while( node )
{
- if( g_strcasecmp( node->name, name ) == 0 )
+ char *colon;
+
+ if( g_strcasecmp( node->name, name ) == 0 ||
+ ( ( colon = strchr( node->name, ':' ) ) &&
+ g_strcasecmp( colon + 1, name ) == 0 ) )
break;
node = node->next;
@@ -460,6 +464,7 @@ struct xt_node *xt_find_node( struct xt_node *node, const char *name )
char *xt_find_attr( struct xt_node *node, const char *key )
{
int i;
+ char *colon;
if( !node )
return NULL;
@@ -468,6 +473,21 @@ char *xt_find_attr( struct xt_node *node, const char *key )
if( g_strcasecmp( node->attr[i].key, key ) == 0 )
break;
+ /* This is an awful hack that only takes care of namespace prefixes
+ inside a tag. Since IMHO excessive namespace usage in XMPP is
+ massive overkill anyway (this code exists for almost four years
+ now and never really missed it): Meh. */
+ if( !node->attr[i].key && strcmp( key, "xmlns" ) == 0 &&
+ ( colon = strchr( node->name, ':' ) ) )
+ {
+ *colon = '\0';
+ for( i = 0; node->attr[i].key; i ++ )
+ if( strncmp( node->attr[i].key, "xmlns:", 6 ) == 0 &&
+ strcmp( node->attr[i].key + 6, node->name ) == 0 )
+ break;
+ *colon = ':';
+ }
+
return node->attr[i].value;
}