comparison libpurple/protocols/jabber/auth.c @ 27039:9a79f8a99259

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).
author Paul Aurich <paul@darkrain42.org>
date Fri, 05 Jun 2009 07:02:16 +0000
parents a0e3e4f37702
children 5fda59132990
comparison
equal deleted inserted replaced
27037:f3b0232ef1ea 27039:9a79f8a99259
987 return; 987 return;
988 } else { 988 } else {
989 response = xmlnode_new("response"); 989 response = xmlnode_new("response");
990 xmlnode_set_namespace(response, "urn:ietf:params:xml:ns:xmpp-sasl"); 990 xmlnode_set_namespace(response, "urn:ietf:params:xml:ns:xmpp-sasl");
991 if (clen > 0) { 991 if (clen > 0) {
992 enc_out = purple_base64_encode((unsigned char*)c_out, clen); 992 /* Cyrus SASL 2.1.22 appears to contain code to add the charset
993 * to the response but there is no possibility it will be executed.
994 * My reading of the digestmd5 plugin indicates the username and
995 * realm are always encoded in UTF-8 (they seem to be the values
996 * we pass in), so we need to ensure charset=utf-8 is set.
997 */
998 if (strstr(c_out, ",charset="))
999 enc_out = purple_base64_encode((unsigned char*)c_out, clen);
1000 else {
1001 char *tmp = g_strdup_printf("%s,charset=utf-8", c_out);
1002 enc_out = purple_base64_encode((unsigned char*)c_out, clen + 14);
1003 g_free(tmp);
1004 }
1005
993 xmlnode_insert_data(response, enc_out, -1); 1006 xmlnode_insert_data(response, enc_out, -1);
994 g_free(enc_out); 1007 g_free(enc_out);
995 } 1008 }
996 jabber_send(js, response); 1009 jabber_send(js, response);
997 xmlnode_free(response); 1010 xmlnode_free(response);