summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert James Kaes <rjkaes@users.sourceforge.net>2002-12-04 17:36:48 +0000
committerRobert James Kaes <rjkaes@users.sourceforge.net>2002-12-04 17:36:48 +0000
commit59ec5dc69fc6719c445155bca1259ad96fc9ae1e (patch)
tree0705ba4452e4fe22fae572df31d600e298bd04a3 /src
parent0a20bdd5b4ea957e108cbf43725349e2766bd1d1 (diff)
downloadtinyproxy-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.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/reqs.c b/src/reqs.c
index d2fd7e3..1f3a9f1 100644
--- a/src/reqs.c
+++ b/src/reqs.c
@@ -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;
}