Ignore:
Timestamp:
2011-12-20T16:45:53Z (12 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
e14b47b8
Parents:
f9789d4
Message:

Detect JID changes at login time and warn the user about them.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    rf9789d4 r68286eb  
    3131{
    3232        struct im_connection *ic = data;
     33        struct jabber_data *jd = ic->proto_data;
    3334        struct xt_node *c, *reply = NULL;
    3435        char *type, *s;
     
    170171                   was added to (or removed from) the buddy list. AFAIK they're
    171172                   sent even if we added this buddy in our own session. */
    172                         int bare_len = strlen( ic->acc->user );
     173                        int bare_len = strlen( jd->me );
    173174                       
    174175                        if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
    175                             ( strncmp( s, ic->acc->user, bare_len ) == 0 &&
     176                            ( strncmp( s, jd->me, bare_len ) == 0 &&
    176177                              ( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
    177178                        {
     
    343344        {
    344345                c = xt_find_node( c->children, "jid" );
    345                 if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
    346                     strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
     346                if( !c || !c->text )
     347                {
     348                        /* Server is crap, but this is no disaster. */
     349                }
     350                else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 )
     351                {
     352                        s = strchr( c->text, '/' );
     353                        if( s )
     354                                *s = '\0';
     355                        jabber_set_me( ic, c->text );
     356                        imcb_log( ic, "Server claims your JID is `%s' instead of `%s'. "
     357                                  "This mismatch may cause problems with groupchats "
     358                                  "and possibly other things.",
     359                                  c->text, ic->acc->user );
     360                        if( s )
     361                                *s = '/';
     362                }
     363                else if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
     364                         strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
    347365                        imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
    348366        }
Note: See TracChangeset for help on using the changeset viewer.