Changeset 54794b8 for protocols/msn


Ignore:
Timestamp:
2006-08-25T12:34:36Z (18 years ago)
Author:
Wilmer van der Gaast <wilmer@…>
Branches:
master
Children:
695e392
Parents:
a36b030
Message:

Added msn_http_encode() so it can be used in msn_buddy_list_add() too.
Most likely fixes #198.

Location:
protocols/msn
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/msn.c

    ra36b030 r54794b8  
    212212static void msn_set_info( struct gaim_connection *gc, char *info )
    213213{
    214         int i;
    215         char buf[1024], *fn, *s;
     214        char buf[1024], *fn;
    216215        struct msn_data *md = gc->proto_data;
    217216       
     
    222221        }
    223222       
    224         /* Of course we could use http_encode() here, but when we encode
    225            every character, the server is less likely to complain about the
    226            chosen name. However, the MSN server doesn't seem to like escaped
    227            non-ASCII chars, so we keep those unescaped. */
    228         s = fn = g_new0( char, strlen( info ) * 3 + 1 );
    229         for( i = 0; info[i]; i ++ )
    230                 if( info[i] & 128 )
    231                 {
    232                         *s = info[i];
    233                         s ++;
    234                 }
    235                 else
    236                 {
    237                         g_snprintf( s, 4, "%%%02X", info[i] );
    238                         s += 3;
    239                 }
     223        fn = msn_http_encode( info );
    240224       
    241225        g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );
  • protocols/msn/msn.h

    ra36b030 r54794b8  
    157157char **msn_linesplit( char *line );
    158158int msn_handler( struct msn_handler_data *h );
     159char *msn_http_encode( const char *input );
    159160
    160161/* tables.c */
  • protocols/msn/msn_util.c

    ra36b030 r54794b8  
    5656        char buf[1024], *realname;
    5757       
    58         realname = g_new0( char, strlen( realname_ ) * 3 + 1 );
    59         strcpy( realname, realname_ );
    60         http_encode( realname );
     58        realname = msn_http_encode( realname_ );
    6159       
    6260        g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname );
     
    315313        return( 1 );
    316314}
     315
     316/* The difference between this function and the normal http_encode() function
     317   is that this one escapes every 7-bit ASCII character because this is said
     318   to avoid some lame server-side checks when setting a real-name. Also,
     319   non-ASCII characters are not escaped because MSN servers don't seem to
     320   appreciate that! */
     321char *msn_http_encode( const char *input )
     322{
     323        char *ret, *s;
     324        int i;
     325       
     326        ret = s = g_new0( char, strlen( input ) * 3 + 1 );
     327        for( i = 0; input[i]; i ++ )
     328                if( input[i] & 128 )
     329                {
     330                        *s = input[i];
     331                        s ++;
     332                }
     333                else
     334                {
     335                        g_snprintf( s, 4, "%%%02X", input[i] );
     336                        s += 3;
     337                }
     338       
     339        return ret;
     340}
Note: See TracChangeset for help on using the changeset viewer.