changeset 29443:d4b9df8e17f6

jabber: Fix another corner case that introduced duplicates to the list. This occurs when the roster contains either two groups with the exact same name or a name that differs only by case. The solution: uniquify the list of groups. Fixes #10950.
author Paul Aurich <paul@darkrain42.org>
date Tue, 16 Feb 2010 00:36:25 +0000
parents 0b6cfe040cd0
children d48173c45606 47aa24b2247c
files ChangeLog libpurple/protocols/jabber/roster.c
diffstat 2 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 15 19:16:38 2010 +0000
+++ b/ChangeLog	Tue Feb 16 00:36:25 2010 +0000
@@ -62,6 +62,9 @@
 	* The default value for the file transfer proxies is automatically
 	  updated when an account connects, if it is still the old (broken)
 	  default (from 'proxy.jabber.org' to 'proxy.eu.jabber.org').
+	* Fix an issue where libpurple created duplicate buddies if the roster
+	  contains a buddy in two groups that differ only by case
+	  (e.g. "XMPP" and "xmpp") (or not at all).
 
 	Yahoo:
 	* Don't send <span> and </span> tags.  (Fartash Faghri)
--- a/libpurple/protocols/jabber/roster.c	Mon Feb 15 19:16:38 2010 +0000
+++ b/libpurple/protocols/jabber/roster.c	Tue Feb 16 00:36:25 2010 +0000
@@ -259,7 +259,16 @@
 					seen_empty = TRUE;
 				}
 
-				groups = g_slist_prepend(groups, group_name);
+				/*
+				 * See the note in add_purple_buddy_to_groups; the core handles
+				 * names case-insensitively and this is required to not
+				 * end up with duplicates if a buddy is in, e.g.,
+				 * 'XMPP' and 'xmpp'
+				 */
+				if (g_slist_find_custom(groups, group_name, (GCompareFunc)purple_utf8_strcasecmp))
+					g_free(group_name);
+				else
+					groups = g_slist_prepend(groups, group_name);
 			}
 
 			add_purple_buddy_to_groups(js, jid, name, groups);