diff options
author | shin <shin@FreeBSD.org> | 2000-02-12 15:16:59 +0000 |
---|---|---|
committer | shin <shin@FreeBSD.org> | 2000-02-12 15:16:59 +0000 |
commit | 0a2a73d5508f74fa8b717c3afbf2c50e4c14150c (patch) | |
tree | 628caf86c4db497afa10a49cf1947eba67d6432d /usr.bin/ftp/fetch.c | |
parent | 4b6c4ae8e8703a11a3fd8ec1108949150418c676 (diff) | |
download | FreeBSD-src-0a2a73d5508f74fa8b717c3afbf2c50e4c14150c.zip FreeBSD-src-0a2a73d5508f74fa8b717c3afbf2c50e4c14150c.tar.gz |
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
Diffstat (limited to 'usr.bin/ftp/fetch.c')
-rw-r--r-- | usr.bin/ftp/fetch.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/usr.bin/ftp/fetch.c b/usr.bin/ftp/fetch.c index fa6a0e4..a494e7e 100644 --- a/usr.bin/ftp/fetch.c +++ b/usr.bin/ftp/fetch.c @@ -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; } |