pidgin: ec06ab42: Set charset=utf-8 when cyrus sasl doesn'...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Fri Jun 5 15:10:35 EDT 2009


-----------------------------------------------------------------
Revision: ec06ab42ff39996dec69ec72c6e3b5689053657b
Ancestor: 4bc859814dd505949045282148a1dc8b22b24b9c
Author: darkrain42 at pidgin.im
Date: 2009-06-05T07:02:16
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/ec06ab42ff39996dec69ec72c6e3b5689053657b

Modified files:
        ChangeLog libpurple/protocols/jabber/auth.c

ChangeLog: 

Set charset=utf-8 when cyrus sasl doesn't include it.

Both deryni and my reading of the digest md5 cyrus plugin is that the response
will never actually include the charset (digestmd5.c:make_client_response,
look for IsUTF8). I future-proofed this code by checking for it anyway.

To be polite for older servers, we might want to only send this if the server
sent charset=utf-8 in the challenge (and encode everything to ISO-8859-1).
However, the RFC doesn't say always sending it is wrong (and that's what
the in-tree implementation does).

-------------- next part --------------
============================================================
--- ChangeLog	711deeecd87b2a066a1efa1c5ebfd61b06507fbb
+++ ChangeLog	a1c6647cae9424891f44b92da778b04b1dc9fec0
@@ -52,6 +52,9 @@ version 2.6.0 (??/??/2009):
 	  chat to avoid getting too many fetch requests).
 	* Fix an issue with Jabber (pre-XMPP) servers and the user's preference
 	  to require SSL not being respected.
+	* Fix an issue where Cyrus SASL DIGEST MD5 authentication might fail if
+	  the username, password, or realm (the JID domain) contain characters
+	  not in ISO-8859-1.
 
 	Yahoo:
 	* P2P file transfers.  (Sulabh Mahajan)
============================================================
--- libpurple/protocols/jabber/auth.c	4846e5134fd09bde6ad21cd0b75b64693e90e5ea
+++ libpurple/protocols/jabber/auth.c	cbc326741d21de7181d9cd7d4ce6b3e79aba10e0
@@ -989,7 +989,20 @@ jabber_auth_handle_challenge(JabberStrea
 			response = xmlnode_new("response");
 			xmlnode_set_namespace(response, "urn:ietf:params:xml:ns:xmpp-sasl");
 			if (clen > 0) {
-				enc_out = purple_base64_encode((unsigned char*)c_out, clen);
+				/* Cyrus SASL 2.1.22 appears to contain code to add the charset
+				 * to the response but there is no possibility it will be executed.
+				 * My reading of the digestmd5 plugin indicates the username and
+				 * realm are always encoded in UTF-8 (they seem to be the values
+				 * we pass in), so we need to ensure charset=utf-8 is set.
+				 */
+				if (strstr(c_out, ",charset="))
+					enc_out = purple_base64_encode((unsigned char*)c_out, clen);
+				else {
+					char *tmp = g_strdup_printf("%s,charset=utf-8", c_out);
+					enc_out = purple_base64_encode((unsigned char*)c_out, clen + 14);
+					g_free(tmp);
+				}
+
 				xmlnode_insert_data(response, enc_out, -1);
 				g_free(enc_out);
 			}


More information about the Commits mailing list