pidgin: ee938b76: Restore the previous behavior (kind of) ...

datallah at pidgin.im datallah at pidgin.im
Thu Dec 16 16:20:48 EST 2010


----------------------------------------------------------------------
Revision: ee938b7680598e11f08cddbb69812a4d70da785b
Parent:   228441c37661b48c2fda6b23d5b98f9982b1e6b2
Author:   ivan.komarov at soc.pidgin.im
Date:     12/16/10 16:18:02
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ee938b7680598e11f08cddbb69812a4d70da785b

Changelog: 

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

Changes against parent 228441c37661b48c2fda6b23d5b98f9982b1e6b2

  patched  libpurple/protocols/oscar/oscar.c

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/oscar.c	0aa016ff1b6c1e247b9e32e5c06a101b59f748ef
+++ libpurple/protocols/oscar/oscar.c	d26c2d6bcfe81c58b036b47d7e8ccd028b062125
@@ -1799,9 +1799,23 @@ incomingim_chan2(OscarData *od, FlapConn
 
 		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. */


More information about the Commits mailing list