Fix parsing problems.
-"ftp hostname:/path" was not working. - IPv6 raw addr specification was not well supported, such as, "ftp http://\[1:2:3:4:5:6:7:8:\]/index.html" Approved by: jkh
This commit is contained in:
parent
2bd54ee847
commit
319c8e321c
@ -527,7 +527,16 @@ bad_ftp_url:
|
||||
if (portnum != NULL)
|
||||
*portnum++ = '\0';
|
||||
} else { /* classic style `host:file' */
|
||||
dir = strchr(host, ':');
|
||||
char *end_brace;
|
||||
|
||||
if (*host == '[' &&
|
||||
(end_brace = strrchr(host, ']')) != NULL) {
|
||||
/*IPv6 addr in []*/
|
||||
host++;
|
||||
*end_brace = '\0';
|
||||
dir = strchr(end_brace + 1, ':');
|
||||
} else
|
||||
dir = strchr(host, ':');
|
||||
}
|
||||
parsed_url:
|
||||
if (EMPTYSTRING(host)) {
|
||||
@ -665,9 +674,19 @@ int
|
||||
isurl(p)
|
||||
const char *p;
|
||||
{
|
||||
char *path, pton_buf[16];
|
||||
|
||||
if (strncasecmp(p, FTP_URL, sizeof(FTP_URL) - 1) == 0
|
||||
|| strncasecmp(p, HTTP_URL, sizeof(HTTP_URL) - 1) == 0) {
|
||||
return 1;
|
||||
}
|
||||
if (*p == '[' && (path = strrchr(p, ']')) != NULL) /*IPv6 addr in []*/
|
||||
return (*(++path) == ':') ? 1 : 0;
|
||||
#ifdef INET6
|
||||
if (inet_pton(AF_INET6, p, pton_buf) == 1) /* raw IPv6 addr */
|
||||
return 0;
|
||||
#endif
|
||||
if (strchr(p, ':') != NULL) /* else, if ':' exist */
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
@ -102,14 +102,23 @@ union sockunion {
|
||||
union sockunion myctladdr, hisctladdr, data_addr;
|
||||
|
||||
char *
|
||||
hookup(host, port)
|
||||
const char *host;
|
||||
hookup(host0, port)
|
||||
const char *host0;
|
||||
char *port;
|
||||
{
|
||||
int s, len, tos, error;
|
||||
struct addrinfo hints, *res, *res0;
|
||||
static char hostnamebuf[MAXHOSTNAMELEN];
|
||||
char *host;
|
||||
|
||||
if (*host0 == '[' && strrchr(host0, ']') != NULL) { /*IPv6 addr in []*/
|
||||
strncpy(hostnamebuf, host0 + 1, strlen(host0) - 2);
|
||||
hostnamebuf[strlen(host0) - 2] = '\0';
|
||||
} else {
|
||||
strncpy(hostnamebuf, host0, strlen(host0));
|
||||
hostnamebuf[strlen(host0)] = '\0';
|
||||
}
|
||||
host = hostnamebuf;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
hints.ai_flags = AI_CANONNAME;
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
|
Loading…
x
Reference in New Issue
Block a user