pidgin: cf77baec: Validate Gadu-Gadu UID's and perform pro...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Sat Nov 29 13:25:34 EST 2008


-----------------------------------------------------------------
Revision: cf77baecd4d76b774c847354badb2e4b2e0164e7
Ancestor: 280dc76b99f56c1c9e8c8c8175e03b356f27f757
Author: ono at java.pl
Date: 2008-11-29T16:50:34
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/cf77baecd4d76b774c847354badb2e4b2e0164e7

Modified files:
        ChangeLog libpurple/protocols/gg/buddylist.c

ChangeLog: 

Validate Gadu-Gadu UID's and perform proper CP1250 to UTF-8 conversions when
handling import and export operations for the buddy list.  Fixes #5694.

-------------- next part --------------
============================================================
--- ChangeLog	54661a79a7e72208e757db4b30847f4b6c1131b0
+++ ChangeLog	f24ca216f8df2e6c4e74ae69149f315146c4f214
@@ -22,6 +22,9 @@ version 2.5.3 (??/??/????):
 	* XMPP resources can now be left blank, causing the server to generate a
 	  resource for us (Jonathan Sailor)
 	* XMPP resources now default to no value
+	* Gadu-Gadu now validates that UID's are valid (Adam Strzelecki)
+	* Gadu-Gadu now does proper charset translations where needed (Adam
+	  Strzelecki)
 
 	Pidgin:
 	* On GTK+ 2.14 and higher, we're using the gtk-tooltip-delay setting
============================================================
--- libpurple/protocols/gg/buddylist.c	353535de7d31ded3a69e0486d86d6d22604f31e6
+++ libpurple/protocols/gg/buddylist.c	ab55dff87edd72a8874c10b6cc39de421c7e1cde
@@ -96,9 +96,10 @@ void ggp_buddylist_load(PurpleConnection
 	PurpleGroup *group;
 	gchar **users_tbl;
 	int i;
+	char *utf8buddylist = charset_convert(buddylist, "CP1250", "UTF-8");
 
 	/* Don't limit the number of records in a buddylist. */
-	users_tbl = g_strsplit(buddylist, "\r\n", -1);
+	users_tbl = g_strsplit(utf8buddylist, "\r\n", -1);
 
 	for (i = 0; users_tbl[i] != NULL; i++) {
 		gchar **data_tbl;
@@ -115,23 +116,22 @@ void ggp_buddylist_load(PurpleConnection
 			continue;
 		}
 
-		show = charset_convert(data_tbl[F_NICKNAME], "CP1250", "UTF-8");
+		show = data_tbl[F_NICKNAME];
 		name = data_tbl[F_UIN];
-		if ('\0' == *name) {
+		if ('\0' == *name || !atol(name)) {
 			purple_debug_warning("gg",
-				"Something is wrong on line %d of the buddylist. Skipping.\n",
+				"Identifier on line %d of the buddylist is not a number. Skipping.\n",
 				i + 1);
 			continue;
 		}
 
 		if ('\0' == *show) {
-			show = g_strdup(name);
+			show = name;
 		}
 
 		purple_debug_info("gg", "got buddy: name=%s; show=%s\n", name, show);
 
 		if (purple_find_buddy(purple_connection_get_account(gc), name)) {
-			g_free(show);
 			g_strfreev(data_tbl);
 			continue;
 		}
@@ -144,7 +144,7 @@ void ggp_buddylist_load(PurpleConnection
 			gchar **group_tbl = g_strsplit(data_tbl[F_GROUP], ",", 50);
 			if (ggp_array_size(group_tbl) > 0) {
 				g_free(g);
-				g = charset_convert(group_tbl[0], "CP1250", "UTF-8");
+				g = g_strdup(group_tbl[0]);
 			}
 			g_strfreev(group_tbl);
 		}
@@ -160,10 +160,10 @@ void ggp_buddylist_load(PurpleConnection
 		purple_blist_add_buddy(buddy, NULL, group, NULL);
 		g_free(g);
 
-		g_free(show);
 		g_strfreev(data_tbl);
 	}
 	g_strfreev(users_tbl);
+	g_free(utf8buddylist);
 
 	ggp_buddylist_send(gc);
 }
@@ -234,8 +234,7 @@ char *ggp_buddylist_dump(PurpleAccount *
 				continue;
 
 			for (bnode = cnode->child; bnode != NULL; bnode = bnode->next) {
-				gchar *newdata, *name, *alias, *gname;
-				gchar *cp_alias, *cp_gname;
+				gchar *name, *alias, *gname;
 
 				if (!PURPLE_BLIST_NODE_IS_BUDDY(bnode))
 					continue;
@@ -248,25 +247,20 @@ char *ggp_buddylist_dump(PurpleAccount *
 				alias = buddy->alias ? buddy->alias : buddy->name;
 				gname = group->name;
 
-				cp_gname = charset_convert(gname, "UTF-8", "CP1250");
-				cp_alias = charset_convert(alias, "UTF-8", "CP1250");
-				newdata = g_strdup_printf(
-						"%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
-						cp_alias, cp_alias, cp_alias, cp_alias,
-						"", cp_gname, name, "", "");
-
 				ptr = buddylist;
-				buddylist = g_strconcat(ptr, newdata, NULL);
+				buddylist = g_strdup_printf(
+						"%s%s;%s;%s;%s;%s;%s;%s;%s%s\r\n",
+						ptr, alias, alias, alias, alias,
+						"", gname, name, "", "");
 
-				g_free(newdata);
 				g_free(ptr);
-				g_free(cp_gname);
-				g_free(cp_alias);
 			}
 		}
 	}
 
-	return buddylist;
+	ptr = charset_convert(buddylist, "UTF-8", "CP1250");
+	g_free(buddylist);
+	return ptr;
 }
 /* }}} */
 


More information about the Commits mailing list