changeset 23646:429cd88862fd

merge of '4c5a026e3419c03409089efe76548d6642ca1e2a' and 'a1515f71238597d861299c4a998b98967c1d6ef9'
author Daniel Atallah <daniel.atallah@gmail.com>
date Fri, 25 Jul 2008 18:50:54 +0000
parents 70d39f235848 (current diff) 1b7dea5ce0cd (diff)
children d48d333e6ef5
files
diffstat 1 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/irc/irc.c	Fri Jul 25 16:03:11 2008 +0000
+++ b/libpurple/protocols/irc/irc.c	Fri Jul 25 18:50:54 2008 +0000
@@ -360,7 +360,8 @@
 
 static gboolean do_login(PurpleConnection *gc) {
 	char *buf, *tmp = NULL;
-	const char *hostname;
+	char *hostname, *server;
+	const char *hosttmp;
 	const char *username, *realname;
 	struct irc_conn *irc = gc->proto_data;
 	const char *pass = purple_connection_get_password(gc);
@@ -374,7 +375,6 @@
 		g_free(buf);
 	}
 
-	hostname = purple_get_host_name();
 	realname = purple_account_get_string(irc->account, "realname", "");
 	username = purple_account_get_string(irc->account, "username", "");
 
@@ -389,9 +389,29 @@
 		}
 	}
 
-	buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : username, hostname, irc->server,
-			      strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
+	hosttmp = purple_get_host_name();
+	if (*hosttmp == ':') {
+		/* This is either an IPv6 address, or something which
+		 * doesn't belong here.  Either way, we need to escape
+		 * it. */
+		hostname = g_strdup_printf("0%s", hosttmp);
+	} else {
+		/* Ugly, I know. */
+		hostname = g_strdup(hosttmp);
+	}
+
+	if (*irc->server == ':') {
+		/* Same as hostname, above. */
+		server = g_strdup_printf("0%s", irc->server);
+	} else {
+		server = g_strdup(irc->server);
+	}
+
+	buf = irc_format(irc, "vvvv:", "USER", tmp ? tmp : username, hostname, server,
+	                 strlen(realname) ? realname : IRC_DEFAULT_ALIAS);
 	g_free(tmp);
+	g_free(hostname);
+	g_free(server);
 	if (irc_send(irc, buf) < 0) {
 		g_free(buf);
 		return FALSE;