changeset 31041:e358c09cd765

Restore the previous behavior (kind of) of falling back to the specified Account-specific encoding when we receive a message without the encoding specified (such as the ones that Miranda sends when "Send Unicode messages" is disabled). Fixes #12778 committer: Daniel Atallah <daniel.atallah@gmail.com>
author ivan.komarov@soc.pidgin.im
date Thu, 16 Dec 2010 21:18:02 +0000
parents 1029e81fe8e5
children 09c46c8f2f8f
files libpurple/protocols/oscar/oscar.c
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/oscar/oscar.c	Thu Dec 16 07:20:13 2010 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Thu Dec 16 21:18:02 2010 +0000
@@ -1799,9 +1799,23 @@
 
 		if (args->info.rtfmsg.msgtype == 1) {
 			if (args->info.rtfmsg.msg != NULL) {
-				char *rtfmsg = oscar_encoding_to_utf8(args->encoding, args->info.rtfmsg.msg, strlen(args->info.rtfmsg.msg));
+				char *rtfmsg;
+				const char *encoding = args->encoding;
+				size_t len = strlen(args->info.rtfmsg.msg);
 				char *tmp, *tmp2;
 
+				if (encoding == NULL && !g_utf8_validate(args->info.rtfmsg.msg, len, NULL)) {
+					/* Yet another wonderful Miranda-related hack. If their user disables the "Send Unicode messages" setting,
+					 * Miranda sends us ch2 messages in whatever Windows codepage is set as default on their user's system (instead of UTF-8).
+					 * Of course, they don't bother to specify that codepage. Let's just fallback to the encoding OUR users can
+					 * specify in account options as a last resort.
+					 */
+					encoding = purple_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING);
+					purple_debug_info("oscar", "Miranda, is that you? Using '%s' as encoding\n", encoding);
+				}
+
+				rtfmsg = oscar_encoding_to_utf8(encoding, args->info.rtfmsg.msg, len);
+
 				/* Channel 2 messages are supposed to be plain-text (never mind the name "rtfmsg", even
 				 * the official client doesn't parse them as RTF). Therefore, we should escape them before
 				 * showing to the user. */