From: wessels <> Date: Tue, 16 Apr 1996 04:52:04 +0000 (+0000) Subject: fixed HTTP URL parsing X-Git-Tag: SQUID_3_0_PRE1~6167 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35dc6615d2e39800e647bcb43a766eef5c7e8cc9;p=thirdparty%2Fsquid.git fixed HTTP URL parsing --- diff --git a/src/http.cc b/src/http.cc index a849b7607c..766b2833e8 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,4 +1,4 @@ -/* $Id: http.cc,v 1.45 1996/04/15 04:08:52 wessels Exp $ */ +/* $Id: http.cc,v 1.46 1996/04/15 22:52:04 wessels Exp $ */ /* * DEBUG: Section 11 http: HTTP @@ -54,21 +54,26 @@ static int http_url_parser(url, host, port, request) char *request; { static char hostbuf[MAX_URL]; - static char atypebuf[MAX_URL]; + static char proto[MAX_URL]; int t; + char *s = NULL; /* initialize everything */ - (*port) = 0; - atypebuf[0] = hostbuf[0] = request[0] = host[0] = '\0'; + (*port) = urlDefaultPort(PROTO_HTTP); + proto[0] = hostbuf[0] = request[0] = host[0] = '\0'; - t = sscanf(url, "%[a-zA-Z]://%[^/]%s", atypebuf, hostbuf, request); - if ((t < 2) || (strcasecmp(atypebuf, "http") != 0)) { + t = sscanf(url, "%[a-zA-Z]://%[^/]%s", proto, hostbuf, request); + if (t < 2) + return -1; + if (strcasecmp(proto, "http") != 0) { return -1; - } else if (t == 2) { + } else if (t == 2) strcpy(request, "/"); + if ((s = strchr(hostbuf, ':')) && *(s+1)) { + *s = '\0'; + *port = atoi(s + 1); } - if (sscanf(hostbuf, "%[^:]:%d", host, port) < 2) - (*port) = urlDefaultPort(PROTO_HTTP); + strncpy(host, hostbuf, SQUIDHOSTNAMELEN); return 0; }