pidgin: cdf3615e: The MSN servers are a bit more strict ab...

qulogic at pidgin.im qulogic at pidgin.im
Fri Oct 23 02:32:22 EDT 2009


-----------------------------------------------------------------
Revision: cdf3615ec8283fb7d859b5cf3cb37855aa10182e
Ancestor: a83c5a439ea7250a77b9d56ccf0dd25cc3ec36d3
Author: qulogic at pidgin.im
Date: 2009-10-23T05:43:50
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/cdf3615ec8283fb7d859b5cf3cb37855aa10182e

Modified files:
        libpurple/protocols/msn/contact.c
        libpurple/protocols/msn/msn.c libpurple/protocols/msn/msn.h
        libpurple/protocols/msn/userlist.c

ChangeLog: 

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.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c	519d981b5f562844dba20b0aa4743f1507d9600d
+++ libpurple/protocols/msn/contact.c	da021691b4925c7412c15b3377e07165563c089a
@@ -362,7 +362,7 @@ msn_parse_each_member(MsnSession *sessio
 	char *display_text;
 
 	passport = xmlnode_get_data(xmlnode_get_child(member, node));
-	if (!purple_email_is_valid(passport)) {
+	if (!msn_email_is_valid(passport)) {
 		g_free(passport);
 		return;
 	}
@@ -765,7 +765,7 @@ msn_parse_addressbook_contacts(MsnSessio
 		if (passport == NULL)
 			continue;
 
-		if (!purple_email_is_valid(passport))
+		if (!msn_email_is_valid(passport))
 			continue;
 
 		if ((displayName = xmlnode_get_child(contactInfo, "displayName")))
============================================================
--- libpurple/protocols/msn/msn.c	f192c99994e15550059ff00e3e4302ffd758a79b
+++ libpurple/protocols/msn/msn.c	1d386d675ac35bbc41a757d53cf30b7dfaeb7d70
@@ -118,6 +118,29 @@ msn_normalize(const PurpleAccount *accou
 	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 @@ msn_add_buddy(PurpleConnection *gc, Purp
 
 	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))
============================================================
--- libpurple/protocols/msn/msn.h	1cd4252e92191eb3b0cf8bfa0ec67e9de4db7aae
+++ libpurple/protocols/msn/msn.h	7bd9590a0d74f6f8154ca6be6838f2fdc7348bca
@@ -133,6 +133,7 @@ typedef enum
 	((MSN_CLIENT_ID_VERSION    << 24) | \
 	 (MSN_CLIENT_ID_CAPABILITIES))
 
+gboolean msn_email_is_valid(const char *passport);
 void msn_act_id(PurpleConnection *gc, const char *entry);
 void msn_send_privacy(PurpleConnection *gc);
 void msn_send_im_message(MsnSession *session, MsnMessage *msg);
============================================================
--- libpurple/protocols/msn/userlist.c	63770d720fd02e8faca4ac3386b747ac9d3aa528
+++ libpurple/protocols/msn/userlist.c	e72232eaee1d9913e7057aee1408ddbe22763039
@@ -539,7 +539,7 @@ msn_userlist_add_buddy(MsnUserList *user
 
 	purple_debug_info("msn", "Add user: %s to group: %s\n", who, new_group_name);
 
-	if (!purple_email_is_valid(who))
+	if (!msn_email_is_valid(who))
 	{
 		/* only notify the user about problems adding to the friends list
 		 * maybe we should do something else for other lists, but it probably


More information about the Commits mailing list