Changeset 3742fb6


Ignore:
Timestamp:
2010-05-11T23:27:11Z (15 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
3429b58, 6e6b3d7
Parents:
f8cb76d
Message:

Implement some kind of ignorant awareness of XML namespaces: Enough to not
break backward compatibility (hopefully) but be able to pick up inappropriate
uses of XML namespace prefixes. Main reason for this change: Fix XMPP typing
notification compatibility with GMail.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/xmltree.c

    rf8cb76d r3742fb6  
    449449        while( node )
    450450        {
    451                 if( g_strcasecmp( node->name, name ) == 0 )
     451                char *colon;
     452               
     453                if( g_strcasecmp( node->name, name ) == 0 ||
     454                    ( ( colon = strchr( node->name, ':' ) ) &&
     455                      g_strcasecmp( colon + 1, name ) == 0 ) )
    452456                        break;
    453457               
     
    461465{
    462466        int i;
     467        char *colon;
    463468       
    464469        if( !node )
     
    468473                if( g_strcasecmp( node->attr[i].key, key ) == 0 )
    469474                        break;
     475       
     476        /* This is an awful hack that only takes care of namespace prefixes
     477           inside a tag. Since IMHO excessive namespace usage in XMPP is
     478           massive overkill anyway (this code exists for almost four years
     479           now and never really missed it): Meh. */
     480        if( !node->attr[i].key && strcmp( key, "xmlns" ) == 0 &&
     481            ( colon = strchr( node->name, ':' ) ) )
     482        {
     483                *colon = '\0';
     484                for( i = 0; node->attr[i].key; i ++ )
     485                        if( strncmp( node->attr[i].key, "xmlns:", 6 ) == 0 &&
     486                            strcmp( node->attr[i].key + 6, node->name ) == 0 )
     487                                break;
     488                *colon = ':';
     489        }
    470490       
    471491        return node->attr[i].value;
Note: See TracChangeset for help on using the changeset viewer.