changeset 22426:5762dcb1909c

Patch #3874 from beret. There was a similar patch #2712 from rschnz, but I think this one is better. Basically the names of ssi items should be UTF-8, and Pidgin currently stores it that way, but when we read it in we call oscar_utf8_try_convert(), which would normally be well and good, but for ICQ accounts that function first tries to treat the name as the character encoding specified in your account preferences. If that converstion happened to succeed it would be incorrect and result in a bad group name. So now we try to treat the string as UTF-8 first.
author Mark Doliner <mark@kingant.net>
date Thu, 06 Mar 2008 07:41:52 +0000
parents a491ebed7f3a
children eab5bc54e163
files libpurple/protocols/oscar/oscar.c
diffstat 1 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Thu Mar 06 07:29:39 2008 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Mar 06 07:41:52 2008 +0000
@@ -4985,8 +4985,13 @@
 
 					groupitem = aim_ssi_itemlist_find(od->ssi.local, curitem->gid, 0x0000);
 					gname = groupitem ? groupitem->name : NULL;
-					gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
-					alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
+					if (gname != NULL) {
+						if (g_utf8_validate(gname, -1, NULL))
+							gname_utf8 = g_strdup(gname);
+						else
+							gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
+					} else
+						gname_utf8 = NULL;
 
 					g = purple_find_group(gname_utf8 ? gname_utf8 : _("Orphans"));
 					if (g == NULL) {
@@ -4994,15 +4999,14 @@
 						purple_blist_add_group(g, NULL);
 					}
 
-					if (alias != NULL)
-					{
+					alias = aim_ssi_getalias(od->ssi.local, gname, curitem->name);
+					if (alias != NULL) {
 						if (g_utf8_validate(alias, -1, NULL))
 							alias_utf8 = g_strdup(alias);
 						else
 							alias_utf8 = oscar_utf8_try_convert(account, alias);
 						g_free(alias);
-					}
-					else
+					} else
 						alias_utf8 = NULL;
 
 					b = purple_find_buddy_in_group(gc->account, curitem->name, g);
@@ -5045,7 +5049,14 @@
 				char *gname_utf8;
 
 				gname = curitem->name;
-				gname_utf8 = gname ? oscar_utf8_try_convert(gc->account, gname) : NULL;
+				if (gname != NULL) {
+					if (g_utf8_validate(gname, -1, NULL))
+						gname_utf8 = g_strdup(gname);
+					else
+						gname_utf8 = oscar_utf8_try_convert(gc->account, gname);
+				} else
+					gname_utf8 = NULL;
+
 				if (gname_utf8 != NULL && purple_find_group(gname_utf8) == NULL) {
 					g = purple_group_new(gname_utf8);
 					purple_blist_add_group(g, NULL);