# HG changeset patch # User ivan.komarov@soc.pidgin.im # Date 1292534282 0 # Node ID e358c09cd765d053933f72b560a91de82168da49 # Parent 1029e81fe8e5cd7cf5f64636169ff104ab4ebc3e 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 diff -r 1029e81fe8e5 -r e358c09cd765 libpurple/protocols/oscar/oscar.c --- 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. */