Index: protocols/jabber/conference.c
===================================================================
--- protocols/jabber/conference.c	(revision 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b)
+++ protocols/jabber/conference.c	(revision 68286eb08dbb6c2aad555f155da6f16ee6f061e8)
@@ -211,4 +211,5 @@
 	struct xt_node *c;
 	char *type = xt_find_attr( node, "type" );
+	struct jabber_data *jd = ic->proto_data;
 	struct jabber_chat *jc;
 	char *s;
@@ -252,5 +253,5 @@
 			if( bud == jc->me )
 			{
-				bud->ext_jid = jabber_normalize( ic->acc->user );
+				bud->ext_jid = g_strdup( jd->me );
 			}
 			else
Index: protocols/jabber/iq.c
===================================================================
--- protocols/jabber/iq.c	(revision 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b)
+++ protocols/jabber/iq.c	(revision 68286eb08dbb6c2aad555f155da6f16ee6f061e8)
@@ -31,4 +31,5 @@
 {
 	struct im_connection *ic = data;
+	struct jabber_data *jd = ic->proto_data;
 	struct xt_node *c, *reply = NULL;
 	char *type, *s;
@@ -170,8 +171,8 @@
 		   was added to (or removed from) the buddy list. AFAIK they're
 		   sent even if we added this buddy in our own session. */
-			int bare_len = strlen( ic->acc->user );
+			int bare_len = strlen( jd->me );
 			
 			if( ( s = xt_find_attr( node, "from" ) ) == NULL ||
-			    ( strncmp( s, ic->acc->user, bare_len ) == 0 &&
+			    ( strncmp( s, jd->me, bare_len ) == 0 &&
 			      ( s[bare_len] == 0 || s[bare_len] == '/' ) ) )
 			{
@@ -343,6 +344,23 @@
 	{
 		c = xt_find_node( c->children, "jid" );
-		if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
-		    strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
+		if( !c || !c->text )
+		{
+			/* Server is crap, but this is no disaster. */
+		}
+		else if( strncmp( jd->me, c->text, strlen( jd->me ) ) != 0 )
+		{
+			s = strchr( c->text, '/' );
+			if( s )
+				*s = '\0';
+			jabber_set_me( ic, c->text );
+			imcb_log( ic, "Server claims your JID is `%s' instead of `%s'. "
+			          "This mismatch may cause problems with groupchats "
+			          "and possibly other things.",
+			          c->text, ic->acc->user );
+			if( s )
+				*s = '/';
+		}
+		else if( c && c->text_len && ( s = strchr( c->text, '/' ) ) &&
+		         strcmp( s + 1, set_getstr( &ic->acc->set, "resource" ) ) != 0 )
 			imcb_log( ic, "Server changed session resource string to `%s'", s + 1 );
 	}
Index: protocols/jabber/jabber.c
===================================================================
--- protocols/jabber/jabber.c	(revision 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b)
+++ protocols/jabber/jabber.c	(revision 68286eb08dbb6c2aad555f155da6f16ee6f061e8)
@@ -111,6 +111,5 @@
 	ic->proto_data = jd;
 	
-	jd->username = g_strdup( acc->user );
-	jd->server = strchr( jd->username, '@' );
+	jabber_set_me( ic, acc->user );
 	
 	jd->fd = jd->r_inpa = jd->w_inpa = -1;
@@ -122,8 +121,4 @@
 		return;
 	}
-	
-	/* So don't think of free()ing jd->server.. :-) */
-	*jd->server = 0;
-	jd->server ++;
 	
 	if( ( s = strchr( jd->server, '/' ) ) )
@@ -314,4 +309,5 @@
 	g_free( jd->away_message );
 	g_free( jd->username );
+	g_free( jd->me );
 	g_free( jd );
 	
@@ -495,9 +491,10 @@
 static void jabber_chat_invite_( struct groupchat *c, char *who, char *msg )
 {
+	struct jabber_data *jd = c->ic->proto_data;
 	struct jabber_chat *jc = c->data;
 	gchar *msg_alt = NULL;
 
 	if( msg == NULL )
-		msg_alt = g_strdup_printf( "%s invited you to %s", c->ic->acc->user, jc->name );
+		msg_alt = g_strdup_printf( "%s invited you to %s", jd->me, jc->name );
 	
 	if( c && who )
Index: protocols/jabber/jabber.h
===================================================================
--- protocols/jabber/jabber.h	(revision 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b)
+++ protocols/jabber/jabber.h	(revision 68286eb08dbb6c2aad555f155da6f16ee6f061e8)
@@ -94,4 +94,5 @@
 	char *username;		/* USERNAME@server */
 	char *server;		/* username@SERVER -=> server/domain, not hostname */
+	char *me;		/* bare jid */
 	
 	const struct oauth2_service *oauth2_service;
@@ -308,4 +309,5 @@
 struct jabber_error *jabber_error_parse( struct xt_node *node, char *xmlns );
 void jabber_error_free( struct jabber_error *err );
+gboolean jabber_set_me( struct im_connection *ic, const char *me );
 
 extern const struct jabber_away_state jabber_away_state_list[];
Index: protocols/jabber/jabber_util.c
===================================================================
--- protocols/jabber/jabber_util.c	(revision 36533bf6bfc01f56afd6a8cd7bd3dfa9de87297b)
+++ protocols/jabber/jabber_util.c	(revision 68286eb08dbb6c2aad555f155da6f16ee6f061e8)
@@ -761,2 +761,20 @@
 	g_free( err );
 }
+
+gboolean jabber_set_me( struct im_connection *ic, const char *me )
+{
+	struct jabber_data *jd = ic->proto_data;
+	
+	if( strchr( me, '@' ) == NULL )
+		return FALSE;
+	
+	g_free( jd->username );
+	g_free( jd->me );
+	
+	jd->me = jabber_normalize( me );
+	jd->server = strchr( jd->me, '@' );
+	jd->username = g_strndup( jd->me, jd->server - jd->me );
+	jd->server ++;
+	
+	return TRUE;
+}
