lynx/lynx-2.8.7-ipv6arg.patch

58 lines
1.6 KiB
Diff
Raw Normal View History

diff --git a/src/LYUtils.c b/src/LYUtils.c
index dd0a3dc..62a0591 100644
--- a/src/LYUtils.c
+++ b/src/LYUtils.c
@@ -2283,9 +2283,10 @@ UrlTypes is_url(char *filename)
return (result);
/*
- * Can't be a URL if it lacks a colon.
+ * Can't be a URL if it lacks a colon and if it starts with '[' it's
+ * probably IPv6 adress.
*/
- if (NULL == strchr(cp, ':'))
+ if (NULL == strchr(cp, ':') || cp[0] == '[')
return (result);
/*
@@ -4549,6 +4550,8 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
#ifdef INET6
struct addrinfo hints, *res;
int error;
+ char *begin;
+ char *end = NULL;
#endif /* INET6 */
/*
@@ -4593,7 +4596,7 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
* field after filling in the host field. - FM
*/
if ((StrColon = strrchr(Str, ':')) != NULL &&
- isdigit(UCH(StrColon[1]))) {
+ isdigit(UCH(StrColon[1])) && strchr(StrColon, ']') == NULL) {
if (StrColon == Str) {
goto cleanup;
}
@@ -4614,10 +4617,20 @@ BOOLEAN LYExpandHostForURL(char **AllocatedString,
fprintf(stdout, "%s '%s'%s\r\n", WWW_FIND_MESSAGE, host, FIRST_SEGMENT);
}
#ifdef INET6
+ begin = host;
+ if (host[0] == '[' && ((end = strrchr(host, ']')))) {
+ /*
+ * cut '[' and ']' from the IPv6 address, e.g. [::1]
+ */
+ begin = host + 1;
+ *end = '\0';
+ }
memset(&hints, 0, sizeof(hints));
hints.ai_family = PF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
- error = getaddrinfo(host, "80", &hints, &res);
+ error = getaddrinfo(begin, "80", &hints, &res);
+ if (end)
+ *end = ']';
if (!error && res)
#else