diff options
Diffstat (limited to 'lib/xmltree.c')
-rw-r--r-- | lib/xmltree.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/xmltree.c b/lib/xmltree.c index 67fe46e1..b0a945ce 100644 --- a/lib/xmltree.c +++ b/lib/xmltree.c @@ -214,7 +214,10 @@ void xt_cleanup( struct xt_parser *xt, struct xt_node *node, int depth ) return; if( node == NULL ) - return xt_cleanup( xt, xt->root, depth ); + { + xt_cleanup( xt, xt->root, depth ); + return; + } if( node->flags & XT_SEEN && node == xt->root ) { @@ -448,7 +451,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 +467,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 +476,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; } |