diff libpurple/protocols/jabber/roster.c @ 29050: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 f7f14706618b
children 351d07aefb09 ae615b3d3e47
line wrap: on
line diff
--- 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);