pidgin: 54ee2acb: This was originally a patch from Brian G...

rekkanoryo at pidgin.im rekkanoryo at pidgin.im
Thu Nov 13 03:45:26 EST 2008


-----------------------------------------------------------------
Revision: 54ee2acb5f6ef92c29503315eb7c24bae221cd7b
Ancestor: 7e2aa3946cbcbd81736f3653115a05c60432bc8a
Author: rekkanoryo at pidgin.im
Date: 2008-11-13T08:39:44
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/54ee2acb5f6ef92c29503315eb7c24bae221cd7b

Modified files:
        COPYRIGHT ChangeLog libpurple/protocols/yahoo/yahoo.c
        libpurple/protocols/yahoo/yahoo.h

ChangeLog: 

This was originally a patch from Brian Geppert that corrected the 'silently
truncates messages at 800 characters' bug in yahoo.  I changed the patch to
reflect the reality I saw, which is that the maximum message length is 946
bytes, but only 800 characters.  It's possible to fall between 800 and 946
bytes but not exceed 800 characters by using multibyte characters.

-------------- next part --------------
============================================================
--- COPYRIGHT	405781307ea0abbc86a2d39902562baac20d84e8
+++ COPYRIGHT	83d59f6159fc576325a039b8fffd48c21e631547
@@ -145,6 +145,7 @@ Georgi Georgiev
 Evgueni V. Gavrilov
 Ignacy Gawedzki
 Georgi Georgiev
+Brian Geppert
 Thomas Gibson-Robinson
 Ike Gingerich
 Gustavo Gir?ldez
============================================================
--- ChangeLog	bc01f43dc470cc1c0546dc534badd54f4d90370f
+++ ChangeLog	f303fd69af0d0a54b1b77f7968ef940fb3b6cc34
@@ -7,6 +7,7 @@ version 2.5.3 (??/??/????):
 	  "Microsoft Internet Authority" certificates.  People that use
 	  --with-system-ssl-certs and GnuTLS need to include these in the
 	  system certs directory.
+	* Corrected maximum message lengths for Yahoo!
 
 	Pidgin:
 	* On GTK+ 2.14 and higher, we're using the gtk-tooltip-delay setting
============================================================
--- libpurple/protocols/yahoo/yahoo.c	7e5229419ad9251d0903c281223a7b90d319ec21
+++ libpurple/protocols/yahoo/yahoo.c	5d25d009744c236c804e85c96c2834426b734de2
@@ -3619,9 +3619,27 @@ static int yahoo_send_im(PurpleConnectio
 	PurpleWhiteboard *wb;
 	int ret = 1;
 	YahooFriend *f = NULL;
+	gsize lenb = 0;
+	glong lenc = 0;
 
 	msg2 = yahoo_string_encode(gc, msg, &utf8);
+	
+	if(msg2) {
+		lenb = strlen(msg2);
+		lenc = g_utf8_strlen(msg2, -1);
 
+		if(lenb > YAHOO_MAX_MESSAGE_LENGTH_BYTES || lenc > YAHOO_MAX_MESSAGE_LENGTH_CHARS) {
+			purple_debug_info("yahoo", "Message too big.  Length is %" G_GSIZE_FORMAT
+					" bytes, %ld characters.  Max is %d bytes, %d chars."
+					"  Message is '%s'.\n", lenb, lenc, YAHOO_MAX_MESSAGE_LENGTH_BYTES,
+					YAHOO_MAX_MESSAGE_LENGTH_CHARS, msg2);
+			yahoo_packet_free(pkt);
+			g_free(msg);
+			g_free(msg2);
+			return -E2BIG;
+		}
+	}
+
 	yahoo_packet_hash(pkt, "ss", 1, purple_connection_get_display_name(gc), 5, who);
 	if ((f = yahoo_friend_find(gc, who)) && f->protocol)
 		yahoo_packet_hash_int(pkt, 241, f->protocol);
============================================================
--- libpurple/protocols/yahoo/yahoo.h	50bc84d9e9f5c3f1da265c8ef93ed880a403a218
+++ libpurple/protocols/yahoo/yahoo.h	10214c200f19cccda1b266feaf214eafc9c35089
@@ -182,6 +182,21 @@ struct yahoo_data {
 
 #define YAHOO_MAX_STATUS_MESSAGE_LENGTH (255)
 
+/*
+ * Current Maximum Length for Instant Messages
+ *
+ * This was found by experiment.
+ *
+ * The YMSG protocol allows a message of up to 948 bytes, but the official client
+ * limits to 800 characters.  According to experiments I conducted, it seems that
+ * the discrepancy is to allow some leeway for messages with mixed single- and
+ * multi-byte characters, as I was able to send messages of 840 and 932 bytes
+ * by using some multibyte characters (some random Chinese or Japanese characters,
+ * to be precise). - rekkanoryo
+ */
+#define YAHOO_MAX_MESSAGE_LENGTH_BYTES 948
+#define YAHOO_MAX_MESSAGE_LENGTH_CHARS 800
+
 /* sometimes i wish prpls could #include things from other prpls. then i could just
  * use the routines from libfaim and not have to admit to knowing how they work. */
 #define yahoo_put16(buf, data) ( \


More information about the Commits mailing list