diff libpurple/protocols/msn/msn.c @ 28790:c3f79073c9be

The MSN servers are a bit more strict about what's allowed in emails than the libpurple utility function. Usually, they just return an error about the specific email and continue on with the rest, but for colons, slashes, question marks, and equal signs, they just disconnect you. So, when adding new contacts, or checking existing contacts in the address book, ignore those with slashes, question marks, and equal signs (colon is already tested). References #9505. Fixes #10549.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Fri, 23 Oct 2009 05:43:50 +0000
parents 77a007e0de1f
children d7c49598cef2 019c8be6b52d
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c	Thu Oct 22 01:21:25 2009 +0000
+++ b/libpurple/protocols/msn/msn.c	Fri Oct 23 05:43:50 2009 +0000
@@ -118,6 +118,29 @@
 	return buf;
 }
 
+gboolean
+msn_email_is_valid(const char *passport)
+{
+	if (purple_email_is_valid(passport)) {
+		/* Special characters aren't allowed in domains, so only go to '@' */
+		while (*passport != '@') {
+			if (*passport == '/')
+				return FALSE;
+			else if (*passport == '?')
+				return FALSE;
+			else if (*passport == '=')
+				return FALSE;
+			/* MSN also doesn't like colons, but that's checked already */
+
+			passport++;
+		}
+
+		return TRUE;
+	}
+
+	return FALSE;
+}
+
 static gboolean
 msn_send_attention(PurpleConnection *gc, const char *username, guint type)
 {
@@ -1511,7 +1534,7 @@
 
 	bname = purple_buddy_get_name(buddy);
 
-	if (!purple_email_is_valid(bname)) {
+	if (!msn_email_is_valid(bname)) {
 		gchar *buf;
 		buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid.  Usernames must be valid email addresses."), bname);
 		if (!purple_conv_present_error(bname, purple_connection_get_account(gc), buf))