changeset 15202:b8ae75fa8d67

[gaim-migrate @ 17992] Attempt to salvage Oscar strings in an invalid encoding, as well as print an error message. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Thu, 14 Dec 2006 04:17:02 +0000
parents 83f0a2d3b441
children f814b2df9cce
files libgaim/protocols/oscar/oscar.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/oscar/oscar.c	Thu Dec 14 01:47:25 2006 +0000
+++ b/libgaim/protocols/oscar/oscar.c	Thu Dec 14 04:17:02 2006 +0000
@@ -426,8 +426,17 @@
 	ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr1, FALSE);
 	if (ret == NULL)
 		ret = gaim_plugin_oscar_convert_to_utf8(data, datalen, charsetstr2, TRUE);
-	if (ret == NULL)
-		ret = g_strdup(_("(There was an error receiving this message.  Either you and the buddy you are speaking to have a different encoding selected, or the buddy has a buggy client.)"));
+	if (ret == NULL) {
+		char *str, *salvage;
+
+		str = g_malloc(datalen + 1);
+		strncpy(str, datalen, data);
+		str[datalen] = '\0';
+		salvage = gaim_utf8_salvage(str);
+		ret = g_strdup_printf(_("%s (There was an error receiving this message.  Either you and the buddy you are speaking to have a different encoding selected, or the buddy has a buggy client.)"), salvage);
+		g_free(str);
+		g_free(salvage);
+        }
 
 	return ret;
 }