[PATCH] Do not keep authentication in URL on connection through a proxy

Clément Bœsch ubitux at gmail.com
Fri Nov 19 14:42:35 CET 2010


---
 stream/network.c |    2 +-
 stream/url.c     |   16 ++++++++++++++++
 stream/url.h     |    1 +
 3 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/stream/network.c b/stream/network.c
index 02ddcc8..74da18f 100644
--- a/stream/network.c
+++ b/stream/network.c
@@ -209,7 +209,7 @@ http_send_request( URL_t *url, off_t pos ) {
 			mp_msg(MSGT_NETWORK, MSGL_ERR, "Invalid URL '%s' to proxify\n", url->file+1);
 			goto err_out;
 		}
-		http_set_uri( http_hdr, server_url->url );
+		http_set_uri( http_hdr, server_url->noauth_url );
 	} else {
 		server_url = url;
 		http_set_uri( http_hdr, server_url->file );
diff --git a/stream/url.c b/stream/url.c
index 0469de9..9ef6e36 100644
--- a/stream/url.c
+++ b/stream/url.c
@@ -65,6 +65,7 @@ url_new(const char* url) {
         char *escfilename=NULL;
 	char *ptr1=NULL, *ptr2=NULL, *ptr3=NULL, *ptr4=NULL;
 	int jumpSize = 3;
+	size_t noauth_len;
 
 	if( url==NULL ) return NULL;
 
@@ -232,6 +233,20 @@ url_new(const char* url) {
 		strcpy(Curl->file, "/");
 	}
 
+	noauth_len = strlen(Curl->protocol) + strlen(Curl->hostname) +
+		strlen(Curl->file) + sizeof("://:65535");
+	Curl->noauth_url = malloc(noauth_len);
+	if (Curl->noauth_url == NULL) {
+		mp_msg(MSGT_NETWORK, MSGL_FATAL, MSGTR_MemAllocFailed);
+		goto err_out;
+	}
+	if (Curl->port)
+		snprintf(Curl->noauth_url, noauth_len, "%s://%s:%d%s",
+			Curl->protocol, Curl->hostname, Curl->port, Curl->file);
+	else
+		snprintf(Curl->noauth_url, noauth_len, "%s://%s%s",
+			Curl->protocol, Curl->hostname, Curl->file);
+
         free(escfilename);
 	return Curl;
 err_out:
@@ -244,6 +259,7 @@ void
 url_free(URL_t* url) {
 	if(!url) return;
 	free(url->url);
+	free(url->noauth_url);
 	free(url->protocol);
 	free(url->hostname);
 	free(url->file);
diff --git a/stream/url.h b/stream/url.h
index fab81ec..c89d91a 100644
--- a/stream/url.h
+++ b/stream/url.h
@@ -27,6 +27,7 @@
 
 typedef struct {
 	char *url;
+	char *noauth_url;
 	char *protocol;
 	char *hostname;
 	char *file;
-- 
1.7.3.2


--CUfgB8w4ZwR/yMy5--


More information about the MPlayer-dev-eng mailing list