diff options
author | Robert James Kaes <rjkaes@users.sourceforge.net> | 2002-12-04 17:36:48 +0000 |
---|---|---|
committer | Robert James Kaes <rjkaes@users.sourceforge.net> | 2002-12-04 17:36:48 +0000 |
commit | 59ec5dc69fc6719c445155bca1259ad96fc9ae1e (patch) | |
tree | 0705ba4452e4fe22fae572df31d600e298bd04a3 /src | |
parent | 0a20bdd5b4ea957e108cbf43725349e2766bd1d1 (diff) | |
download | tinyproxy-59ec5dc69fc6719c445155bca1259ad96fc9ae1e.tar.gz tinyproxy-59ec5dc69fc6719c445155bca1259ad96fc9ae1e.zip |
(strip_username_password): New function to remove any
username/password part from the host URI.
(extract_http_url), (extract_ssl_url): Use the new
strip_username_password function to remove any non-host information
from the URI.
Diffstat (limited to 'src')
-rw-r--r-- | src/reqs.c | 28 |
1 files changed, 27 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: reqs.c,v 1.88 2002-12-04 17:06:13 rjkaes Exp $ +/* $Id: reqs.c,v 1.89 2002-12-04 17:36:48 rjkaes Exp $ * * This is where all the work in tinyproxy is actually done. Incoming * connections have a new child created for them. The child then @@ -190,6 +190,26 @@ free_request_struct(struct request_s *request) } /* + * Take a host string and if there is a username/password part, strip + * it off. + */ +static void +strip_username_password(char* host) +{ + char *ptr1, *ptr2; + + if ((ptr1 = strchr(host, '@')) != NULL) { + ptr1++; /* move to one past the @ symbol */ + ptr2 = host; + + /* copy the bytes up to the NUL */ + while (*ptr1) + *ptr2++ = *ptr1++; + *ptr2 = '\0'; + } +} + +/* * Pull the information out of the URL line. This will handle both HTTP * and FTP (proxied) URLs. */ @@ -218,6 +238,9 @@ extract_http_url(const char *url, struct request_s *request) goto ERROR_EXIT; } + /* Remove the username/password if they're present */ + strip_username_password(request->host); + return 0; ERROR_EXIT: @@ -249,6 +272,9 @@ extract_ssl_url(const char *url, struct request_s *request) return -1; } + /* Remove the username/password if they're present */ + strip_username_password(request->host); + return 0; } |