aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/msn/msn_util.c
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2006-08-25 14:34:36 +0200
committerWilmer van der Gaast <wilmer@gaast.net>2006-08-25 14:34:36 +0200
commit54794b8e01b5cce0675e9cfbd7282d011ebcb99e (patch)
tree9303652695925852ee897b54c90c59e0ca24fc78 /protocols/msn/msn_util.c
parenta36b030d747a39fed8224e6350d56d55b2aec4e2 (diff)
Added msn_http_encode() so it can be used in msn_buddy_list_add() too.
Most likely fixes #198.
Diffstat (limited to 'protocols/msn/msn_util.c')
-rw-r--r--protocols/msn/msn_util.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/protocols/msn/msn_util.c b/protocols/msn/msn_util.c
index 4e748099..ff4c148c 100644
--- a/protocols/msn/msn_util.c
+++ b/protocols/msn/msn_util.c
@@ -55,9 +55,7 @@ int msn_buddy_list_add( struct gaim_connection *gc, char *list, char *who, char
struct msn_data *md = gc->proto_data;
char buf[1024], *realname;
- realname = g_new0( char, strlen( realname_ ) * 3 + 1 );
- strcpy( realname, realname_ );
- http_encode( realname );
+ realname = msn_http_encode( realname_ );
g_snprintf( buf, sizeof( buf ), "ADD %d %s %s %s\r\n", ++md->trId, list, who, realname );
if( msn_write( gc, buf, strlen( buf ) ) )
@@ -314,3 +312,29 @@ int msn_handler( struct msn_handler_data *h )
return( 1 );
}
+
+/* The difference between this function and the normal http_encode() function
+ is that this one escapes every 7-bit ASCII character because this is said
+ to avoid some lame server-side checks when setting a real-name. Also,
+ non-ASCII characters are not escaped because MSN servers don't seem to
+ appreciate that! */
+char *msn_http_encode( const char *input )
+{
+ char *ret, *s;
+ int i;
+
+ ret = s = g_new0( char, strlen( input ) * 3 + 1 );
+ for( i = 0; input[i]; i ++ )
+ if( input[i] & 128 )
+ {
+ *s = input[i];
+ s ++;
+ }
+ else
+ {
+ g_snprintf( s, 4, "%%%02X", input[i] );
+ s += 3;
+ }
+
+ return ret;
+}