Index: protocols/msn/msn.c
===================================================================
--- protocols/msn/msn.c	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ protocols/msn/msn.c	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -366,5 +366,5 @@
 	struct gaim_connection *gc = acc->gc;
 	struct msn_data *md;
-	char buf[1024], *fn, *s;
+	char buf[1024], *fn;
 	int i;
 	
@@ -381,20 +381,5 @@
 	}
 	
-	/* Of course we could use http_encode() here, but when we encode
-	   every character, the server is less likely to complain about the
-	   chosen name. However, the MSN server doesn't seem to like escaped
-	   non-ASCII chars, so we keep those unescaped. */
-	s = fn = g_new0( char, strlen( value ) * 3 + 1 );
-	for( i = 0; value[i]; i ++ )
-		if( value[i] & 128 )
-		{
-			*s = value[i];
-			s ++;
-		}
-		else
-		{
-			g_snprintf( s, 4, "%%%02X", value[i] );
-			s += 3;
-		}
+	fn = msn_http_encode( value );
 	
 	g_snprintf( buf, sizeof( buf ), "REA %d %s %s\r\n", ++md->trId, gc->username, fn );
Index: protocols/msn/msn.h
===================================================================
--- protocols/msn/msn.h	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ protocols/msn/msn.h	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -157,4 +157,5 @@
 char **msn_linesplit( char *line );
 int msn_handler( struct msn_handler_data *h );
+char *msn_http_encode( const char *input );
 
 /* tables.c */
Index: protocols/msn/msn_util.c
===================================================================
--- protocols/msn/msn_util.c	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ protocols/msn/msn_util.c	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -54,20 +54,7 @@
 {
 	struct msn_data *md = gc->proto_data;
-	GSList *l, **lp = NULL;
 	char buf[1024], *realname;
 	
-	if( strcmp( list, "AL" ) == 0 )
-		lp = &gc->permit;
-	else if( strcmp( list, "BL" ) == 0 )
-		lp = &gc->deny;
-	
-	if( lp )
-		for( l = *lp; l; l = l->next )
-			if( g_strcasecmp( l->data, who ) == 0 )
-				return( 1 );
-	
-	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 );
@@ -76,7 +63,4 @@
 		g_free( realname );
 		
-		if( lp )
-			*lp = g_slist_append( *lp, g_strdup( who ) );
-		
 		return( 1 );
 	}
@@ -90,30 +74,9 @@
 {
 	struct msn_data *md = gc->proto_data;
-	GSList *l = NULL, **lp = NULL;
 	char buf[1024];
-	
-	if( strcmp( list, "AL" ) == 0 )
-		lp = &gc->permit;
-	else if( strcmp( list, "BL" ) == 0 )
-		lp = &gc->deny;
-	
-	if( lp )
-	{
-		for( l = *lp; l; l = l->next )
-			if( g_strcasecmp( l->data, who ) == 0 )
-				break;
-		
-		if( !l )
-			return( 1 );
-	}
 	
 	g_snprintf( buf, sizeof( buf ), "REM %d %s %s\r\n", ++md->trId, list, who );
 	if( msn_write( gc, buf, strlen( buf ) ) )
-	{
-		if( lp )
-			*lp = g_slist_remove( *lp, l->data );
-		
 		return( 1 );
-	}
 	
 	return( 0 );
@@ -350,2 +313,28 @@
 	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;
+}
Index: protocols/msn/passport.c
===================================================================
--- protocols/msn/passport.c	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ protocols/msn/passport.c	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -59,4 +59,5 @@
 	rep->data = data;
 	rep->func = func;
+	rep->header = header;
 	
 	server = g_strdup( prd_cached );
@@ -125,7 +126,11 @@
 static char *passport_create_header( char *cookie, char *email, char *pwd )
 {
-	char *buffer = g_new0( char, 2048 );
+	char *buffer;
 	char *currenttoken;
 	char *email_enc, *pwd_enc;
+	
+	currenttoken = strstr( cookie, "lc=" );
+	if( currenttoken == NULL )
+		return NULL;
 	
 	email_enc = g_new0( char, strlen( email ) * 3 + 1 );
@@ -137,18 +142,13 @@
 	http_encode( pwd_enc );
 	
-	currenttoken = strstr( cookie, "lc=" );
-	if( currenttoken == NULL )
-		return( NULL );
-	
-	g_snprintf( buffer, 2048,
-	            "Authorization: Passport1.4 OrgVerb=GET,"
-	            "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
-	            "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
-	            currenttoken );
+	buffer = g_strdup_printf( "Authorization: Passport1.4 OrgVerb=GET,"
+	                          "OrgURL=http%%3A%%2F%%2Fmessenger%%2Emsn%%2Ecom,"
+	                          "sign-in=%s,pwd=%s,%s", email_enc, pwd_enc,
+	                          currenttoken );
 	
 	g_free( email_enc );
 	g_free( pwd_enc );
 	
-	return( buffer );
+	return buffer;
 }
 
Index: protocols/yahoo/yahoo.c
===================================================================
--- protocols/yahoo/yahoo.c	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ protocols/yahoo/yahoo.c	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -192,11 +192,16 @@
 	gc->away = NULL;
 	
-	if( msg )
+	if( state && msg && g_strcasecmp( state, msg ) != 0 )
 	{
 		yd->current_status = YAHOO_STATUS_CUSTOM;
 		gc->away = "";
 	}
-	if( state )
-	{
+	else if( state )
+	{
+		/* Set msg to NULL since (if it isn't NULL already) it's equal
+		   to state. msg must be empty if we want to use an existing
+		   away state. */
+		msg = NULL;
+		
 		gc->away = "";
 		if( g_strcasecmp( state, "Available" ) == 0 )
@@ -235,8 +240,5 @@
 		yd->current_status = YAHOO_STATUS_AVAILABLE;
 	
-	if( yd->current_status == YAHOO_STATUS_INVISIBLE )
-		yahoo_set_away( yd->y2_id, yd->current_status, NULL, gc->away != NULL );
-	else
-		yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
+	yahoo_set_away( yd->y2_id, yd->current_status, msg, gc->away != NULL );
 }
 
Index: root_commands.c
===================================================================
--- root_commands.c	(revision 3ef6410bab141e5c6ea465730a37289991c38f9f)
+++ root_commands.c	(revision e97827bee83d3a0663aa284e72a4f6c84b4b4dfe)
@@ -656,5 +656,5 @@
 		
 		irc_usermsg( irc, format, "Handle", "Nickname" );
-		for( l = a->gc->deny; l; l = l->next )
+		for( l = a->gc->permit; l; l = l->next )
 		{
 			user_t *u = user_findhandle( a->gc, l->data );
