changeset 27016:22bcf150f6c7

merge of '84a23ef59e6a3bc88834f0948c67516f0a39234b' and 'c6d740f231b3d74f01b3afece4a09e6e4cde36a9'
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Wed, 03 Jun 2009 17:09:18 +0000
parents e696a0740a85 (diff) 1b47eb4abf96 (current diff)
children e6f8354c70c6 bf9db4c67679
files ChangeLog
diffstat 3 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Jun 03 17:08:25 2009 +0000
+++ b/ChangeLog	Wed Jun 03 17:09:18 2009 +0000
@@ -50,6 +50,8 @@
 	  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.
+	* When using non-Cyrus SASL DIGEST-MD5 authentication, only specify the
+	  charset as UTF-8 if the username/password weren't converted to ISO-8859-1.
 
 	Yahoo:
 	* P2P file transfers.  (Sulabh Mahajan)
--- a/libpurple/protocols/jabber/auth.c	Wed Jun 03 17:08:25 2009 +0000
+++ b/libpurple/protocols/jabber/auth.c	Wed Jun 03 17:09:18 2009 +0000
@@ -784,22 +784,29 @@
 
 static char *
 generate_response_value(JabberID *jid, const char *passwd, const char *nonce,
-		const char *cnonce, const char *a2, const char *realm)
+		const char *cnonce, const char *a2, const char *realm,
+		gboolean *converted)
 {
 	PurpleCipher *cipher;
 	PurpleCipherContext *context;
 	guchar result[16];
 	size_t a1len;
+	gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z;
 
-	gchar *a1, *convnode=NULL, *convpasswd = NULL, *ha1, *ha2, *kd, *x, *z;
+	if (converted)
+		*converted = TRUE;
 
 	if((convnode = g_convert(jid->node, -1, "iso-8859-1", "utf-8",
 					NULL, NULL, NULL)) == NULL) {
 		convnode = g_strdup(jid->node);
+		if (converted)
+			*converted = FALSE;
 	}
 	if(passwd && ((convpasswd = g_convert(passwd, -1, "iso-8859-1",
 						"utf-8", NULL, NULL, NULL)) == NULL)) {
 		convpasswd = g_strdup(passwd);
+		if (converted)
+			*converted = FALSE;
 	}
 
 	cipher = purple_ciphers_find_cipher("md5");
@@ -914,18 +921,19 @@
 				char *auth_resp;
 				char *buf;
 				char *cnonce;
+				gboolean converted_to_iso8859;
 
 				cnonce = g_strdup_printf("%x%u%x", g_random_int(), (int)time(NULL),
 						g_random_int());
 
 				a2 = g_strdup_printf("AUTHENTICATE:xmpp/%s", realm);
 				auth_resp = generate_response_value(js->user,
-						purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
+						purple_connection_get_password(js->gc), nonce, cnonce, a2, realm, &converted_to_iso8859);
 				g_free(a2);
 
 				a2 = g_strdup_printf(":xmpp/%s", realm);
 				js->expected_rspauth = generate_response_value(js->user,
-						purple_connection_get_password(js->gc), nonce, cnonce, a2, realm);
+						purple_connection_get_password(js->gc), nonce, cnonce, a2, realm, &converted_to_iso8859);
 				g_free(a2);
 
 				g_string_append_printf(response, "username=\"%s\"", js->user->node);
@@ -936,7 +944,8 @@
 				g_string_append_printf(response, ",qop=auth");
 				g_string_append_printf(response, ",digest-uri=\"xmpp/%s\"", realm);
 				g_string_append_printf(response, ",response=%s", auth_resp);
-				g_string_append_printf(response, ",charset=utf-8");
+				if (!converted_to_iso8859)
+					g_string_append_printf(response, ",charset=utf-8");
 
 				g_free(auth_resp);
 				g_free(cnonce);
--- a/libpurple/protocols/jabber/jabber.c	Wed Jun 03 17:08:25 2009 +0000
+++ b/libpurple/protocols/jabber/jabber.c	Wed Jun 03 17:09:18 2009 +0000
@@ -1124,10 +1124,6 @@
 	if (type != JABBER_IQ_RESULT)
 		return;
 
-	if (!from)
-		from = js->serverFQDN;
-	g_return_if_fail(from != NULL);
-
 	if(js->registration) {
 		/* get rid of the login thingy */
 		purple_connection_set_state(js->gc, PURPLE_CONNECTED);