Changeset 757515a


Ignore:
Timestamp:
2014-07-24T03:51:07Z (10 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
1783ab6
Parents:
778ea8a
git-author:
GRMrGecko <GRMrGecko@…> (24-07-14 03:51:07)
git-committer:
dequis <dx@…> (24-07-14 03:51:07)
Message:

Added jabber_compare_jid to fix JID comparison case sensitivity

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • protocols/jabber/iq.c

    r778ea8a r757515a  
    352352                        /* Server is crap, but this is no disaster. */
    353353                }
    354                 else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 )
     354                else if( jabber_compare_jid( jd->me, c->text ) == 0 )
    355355                {
    356356                        s = strchr( c->text, '/' );
  • protocols/jabber/jabber.h

    r778ea8a r757515a  
    289289const struct jabber_away_state *jabber_away_state_by_name( char *name );
    290290void jabber_buddy_ask( struct im_connection *ic, char *handle );
     291int jabber_compare_jid( const char *jid1, const char *jid2 );
    291292char *jabber_normalize( const char *orig );
    292293
  • protocols/jabber/jabber_util.c

    r778ea8a r757515a  
    306306        imcb_ask( ic, buf, bla, jabber_buddy_ask_yes, jabber_buddy_ask_no );
    307307        g_free( buf );
     308}
     309
     310/* Compares two Jabber IDs to check for match. */
     311int jabber_compare_jid( const char *jid1, const char *jid2 )
     312{
     313        int i;
     314       
     315        for( i = 0; ; i ++ )
     316        {
     317                if( jid1[i] == '\0' || jid1[i] == '/' || jid2[i] == '\0' || jid2[i] == '/' )
     318                {
     319                        if( ( jid1[i] == '\0' || jid1[i] == '/' ) && ( jid2[i] == '\0' || jid2[i] == '/' ) )
     320                                break;
     321                        return FALSE;
     322                }
     323                if( tolower( jid1[i] ) != tolower( jid2[i] ) )
     324                {
     325                        return FALSE;
     326                }
     327        }
     328       
     329        return TRUE;
    308330}
    309331
  • tests/check_jabber_util.c

    r778ea8a r757515a  
    9595}
    9696
     97static void check_compareJID(int l)
     98{
     99        fail_unless( jabber_compare_jid( "bugtest@google.com/B", "bugtest@google.com/A" ) );
     100        fail_if( jabber_compare_jid( "bugtest1@google.com/B", "bugtest@google.com/A" ) );
     101        fail_if( jabber_compare_jid( "bugtest@google.com/B", "bugtest1@google.com/A" ) );
     102        fail_if( jabber_compare_jid( "bugtest1@google.com/B", "bugtest2@google.com/A" ) );
     103        fail_unless( jabber_compare_jid( "bugtest@google.com/A", "bugtest@google.com/A" ) );
     104        fail_if( jabber_compare_jid( "", "bugtest@google.com/A" ) );
     105}
     106
    97107Suite *jabber_util_suite (void)
    98108{
     
    110120        suite_add_tcase (s, tc_core);
    111121        tcase_add_test (tc_core, check_buddy_add);
     122        tcase_add_test (tc_core, check_compareJID);
    112123        return s;
    113124}
Note: See TracChangeset for help on using the changeset viewer.