aboutsummaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/url.c b/lib/url.c
index 64d4c2a2d..cc6b64748 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -2149,6 +2149,33 @@ static CURLcode CreateConnection(struct SessionHandle *data,
if(proxy && *proxy) {
/* we have a proxy here to set */
+ char *ptr;
+ char user[MAX_CURL_USER_LENGTH];
+ char passwd[MAX_CURL_PASSWORD_LENGTH];
+
+ /* skip the possible protocol piece */
+ ptr=strstr(proxy, "://");
+ if(ptr)
+ ptr += 3;
+ else
+ ptr = proxy;
+
+ /* check for an @-letter */
+ ptr = strchr(ptr, '@');
+ if(ptr && (2 == sscanf(proxy, "%" MAX_CURL_USER_LENGTH_TXT"[^:]:"
+ "%" MAX_CURL_PASSWORD_LENGTH_TXT "[^@]",
+ user, passwd))) {
+ /* found user and password, rip them out */
+ strcpy(data->state.proxyuser, user);
+ strcpy(data->state.proxypasswd, passwd);
+ conn->bits.proxy_user_passwd = TRUE; /* enable it */
+
+ ptr = strdup(ptr+1);
+ free(proxy); /* free the former data */
+ proxy = ptr; /* now use this instead */
+ }
+
+
data->change.proxy = proxy;
data->change.proxy_alloc=TRUE; /* this needs to be freed later */
conn->bits.httpproxy = TRUE;