- allow IPv6 addresses without http:// prefix (#425879)

This commit is contained in:
Kamil Dudka 2010-04-07 22:59:36 +00:00
parent 880b841b09
commit 6399ca3706
2 changed files with 65 additions and 1 deletions

57
lynx-2.8.7-ipv6arg.patch Normal file
View File

@ -0,0 +1,57 @@
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

View File

@ -1,7 +1,7 @@
Summary: A text-based Web browser
Name: lynx
Version: 2.8.7
Release: 3%{?dist}
Release: 4%{?dist}
License: GPLv2
Group: Applications/Internet
Source: http://lynx.isc.org/lynx%{version}/lynx%{version}.tar.bz2
@ -30,6 +30,9 @@ Patch4: lynx-2.8.7-bm-del.patch
# avoid build failure caused by mistakenly excluded <locale.h>
Patch5: lynx-2.8.7-locale.patch
# bz #425879
Patch6: lynx-2.8.7-ipv6arg.patch
Provides: webclient
Provides: text-www-browser
BuildRequires: gettext
@ -58,6 +61,7 @@ exits quickly and swiftly displays web pages.
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
perl -pi -e "s,^HELPFILE:.*,HELPFILE:file://localhost/usr/share/doc/lynx-%{version}/lynx_help/lynx_help_main.html,g" lynx.cfg
perl -pi -e "s,^DEFAULT_INDEX_FILE:.*,DEFAULT_INDEX_FILE:http://www.google.com/,g" lynx.cfg
@ -145,6 +149,9 @@ rm -rf $RPM_BUILD_ROOT
%config(noreplace,missingok) %{_sysconfdir}/lynx-site.cfg
%changelog
* Thu Apr 08 2010 Kamil Dudka <kdudka@redhat.com> - 2.8.7-4
- allow IPv6 addresses without http:// prefix (#425879)
* Wed Apr 07 2010 Kamil Dudka <kdudka@redhat.com> - 2.8.7-3
- avoid build failure caused by mistakenly excluded <locale.h>