changeset 31418:2812bbd3fc18

Stop escaping all characters in the display name. It's only necessary to escape percent and space, and the UTF-8 can be left alone. Fixes #8508.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 28 Nov 2010 07:24:22 +0000
parents f26e961e1274
children 7300259608c9
files ChangeLog libpurple/protocols/msn/msn.c
diffstat 2 files changed, 38 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Nov 28 02:15:18 2010 +0000
+++ b/ChangeLog	Sun Nov 28 07:24:22 2010 +0000
@@ -14,7 +14,10 @@
 	  libgadu to 1.9.0. (#12789)
 
 	MSN:
-	* Don't show ourselves in the list of endpoints that can be disconnected.
+	* Stop showing ourselves in the list of endpoints that can be
+	  disconnected.
+	* Allow full-size display names, by not escaping (most) non-English
+	  characters. (#8508)
 
 version 2.7.7 (11/23/2010):
 	General:
--- a/libpurple/protocols/msn/msn.c	Sun Nov 28 02:15:18 2010 +0000
+++ b/libpurple/protocols/msn/msn.c	Sun Nov 28 07:24:22 2010 +0000
@@ -250,24 +250,44 @@
 	MsnSession *session;
 	MsnTransaction *trans;
 	PurpleAccount *account;
-	const char *real_alias;
+	char real_alias[BUDDY_ALIAS_MAXLEN+1];
 	struct public_alias_closure *closure;
 
 	session = purple_connection_get_protocol_data(pc);
 	cmdproc = session->notification->cmdproc;
 	account = purple_connection_get_account(pc);
 
-	if (alias && *alias)
-	{
-		char *tmp = g_strdup(alias);
-		real_alias = purple_url_encode(g_strstrip(tmp));
-		g_free(tmp);
-	}
-	else
-		real_alias = "";
-
-	if (strlen(real_alias) > BUDDY_ALIAS_MAXLEN)
-	{
+	if (alias && *alias) {
+		int i = 0;
+		while (isspace(*alias))
+			alias++;
+
+		for (; *alias && i < BUDDY_ALIAS_MAXLEN; alias++) {
+			if (*alias == '%') {
+				if (i > BUF_LEN - 4)
+					break;
+				real_alias[i++] = '%';
+				real_alias[i++] = '2';
+				real_alias[i++] = '5';
+			} else if (*alias == ' ') {
+				if (i > BUF_LEN - 4)
+					break;
+				real_alias[i++] = '%';
+				real_alias[i++] = '2';
+				real_alias[i++] = '0';
+			} else {
+				real_alias[i++] = *alias;
+			}
+		}
+
+		while (i && isspace(real_alias[i - 1]))
+			i--;
+
+		real_alias[i] = '\0';
+	} else
+		real_alias[0] = '\0';
+
+	if (*alias) {
 		if (failure_cb) {
 			struct public_alias_closure *closure =
 				g_new0(struct public_alias_closure, 1);
@@ -282,8 +302,8 @@
 		return;
 	}
 
-	if (*real_alias == '\0') {
-		real_alias = purple_url_encode(purple_account_get_username(account));
+	if (real_alias[0] == '\0') {
+		strcpy(real_alias, purple_account_get_username(account));
 	}
 
 	closure = g_new0(struct public_alias_closure, 1);