# HG changeset patch # User Paul Aurich # Date 1259819170 0 # Node ID 0437b62ffaa52d0357d2c0bcc78b4b0e7df4133b # Parent d558d141aaae078ca108fb37fb5beac837c2b939# Parent 6846e88e76e35d2e8ccb8ae897591ab12e7a969f propagate from branch 'im.pidgin.pidgin' (head 9ba62902a7be15503ccd0006cd59c73fecc6255c) to branch 'im.pidgin.cpw.darkrain42.xmpp.scram' (head 79a53ad8e9ddee4697728b291394382ce35069b5) diff -r d558d141aaae -r 0437b62ffaa5 ChangeLog --- a/ChangeLog Thu Dec 03 05:39:00 2009 +0000 +++ b/ChangeLog Thu Dec 03 05:46:10 2009 +0000 @@ -15,6 +15,9 @@ * Actually emit the hold signal for media calls. * Fix building the GnuTLS plugin with older versions of GnuTLS. * Fix DNS TXT query resolution. + * Don't send Proxy-Authorization headers to HTTP proxy servers until we've + received a "407 Proxy Authentication Required" response from the server. + (thecrux) * Added "MXit" protocol plugin, supported and maintained by the MXit folks themselves (MXit Lifestyle (Pty) Ltd.) diff -r d558d141aaae -r 0437b62ffaa5 libpurple/proxy.c --- a/libpurple/proxy.c Thu Dec 03 05:39:00 2009 +0000 +++ b/libpurple/proxy.c Thu Dec 03 05:46:10 2009 +0000 @@ -1098,6 +1098,36 @@ connect_data->host, connect_data->port, connect_data->host, connect_data->port); + if (purple_proxy_info_get_username(connect_data->gpi) != NULL) + { + char *t1, *t2, *ntlm_type1; + char hostname[256]; + + ret = gethostname(hostname, sizeof(hostname)); + hostname[sizeof(hostname) - 1] = '\0'; + if (ret < 0 || hostname[0] == '\0') { + purple_debug_warning("proxy", "gethostname() failed -- is your hostname set?"); + strcpy(hostname, "localhost"); + } + + t1 = g_strdup_printf("%s:%s", + purple_proxy_info_get_username(connect_data->gpi), + purple_proxy_info_get_password(connect_data->gpi) ? + purple_proxy_info_get_password(connect_data->gpi) : ""); + t2 = purple_base64_encode((const guchar *)t1, strlen(t1)); + g_free(t1); + + ntlm_type1 = purple_ntlm_gen_type1(hostname, ""); + + g_string_append_printf(request, + "Proxy-Authorization: Basic %s\r\n" + "Proxy-Authorization: NTLM %s\r\n" + "Proxy-Connection: Keep-Alive\r\n", + t2, ntlm_type1); + g_free(ntlm_type1); + g_free(t2); + } + g_string_append(request, "\r\n"); connect_data->write_buf_len = request->len;