# HG changeset patch # User Elliott Sales de Andrade # Date 1256276630 0 # Node ID c3f79073c9bec3abbc5118319d7dea4efd44407b # Parent e7bb163434c75e901e00abd054dd37f6789a6d60 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. diff -r e7bb163434c7 -r c3f79073c9be libpurple/protocols/msn/contact.c --- a/libpurple/protocols/msn/contact.c Thu Oct 22 01:21:25 2009 +0000 +++ b/libpurple/protocols/msn/contact.c Fri Oct 23 05:43:50 2009 +0000 @@ -362,7 +362,7 @@ 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 @@ if (passport == NULL) continue; - if (!purple_email_is_valid(passport)) + if (!msn_email_is_valid(passport)) continue; if ((displayName = xmlnode_get_child(contactInfo, "displayName"))) diff -r e7bb163434c7 -r c3f79073c9be libpurple/protocols/msn/msn.c --- 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)) diff -r e7bb163434c7 -r c3f79073c9be libpurple/protocols/msn/msn.h --- a/libpurple/protocols/msn/msn.h Thu Oct 22 01:21:25 2009 +0000 +++ b/libpurple/protocols/msn/msn.h Fri Oct 23 05:43:50 2009 +0000 @@ -133,6 +133,7 @@ ((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); diff -r e7bb163434c7 -r c3f79073c9be libpurple/protocols/msn/userlist.c --- a/libpurple/protocols/msn/userlist.c Thu Oct 22 01:21:25 2009 +0000 +++ b/libpurple/protocols/msn/userlist.c Fri Oct 23 05:43:50 2009 +0000 @@ -539,7 +539,7 @@ 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