aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--main.c11
-rw-r--r--url.c20
3 files changed, 28 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index d638e2f..62fba05 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2001-11-24 Akihiro Sagawa <sagawa@sohgoh.net>
+
+ * [w3m-dev 02528] RFC2732 URL Patch
+ * main.c (chkURL): check RFC2732 style URLs
+ * url.c (parseURL): remove RFC2732 address check here,
+ move to openSocket()
+ * url.c (openSocket): check RFC2732 style hostname
+ * url.c (openSocket): check IPv4 address strictly
+
2001-11-24 Fumitoshi UKAI <ukai@debian.or.jp>
* [w3m-dev 02526]
diff --git a/main.c b/main.c
index 636eb0c..c1de7a9 100644
--- a/main.c
+++ b/main.c
@@ -1,4 +1,4 @@
-/* $Id: main.c,v 1.17 2001/11/23 19:00:47 ukai Exp $ */
+/* $Id: main.c,v 1.18 2001/11/23 20:06:40 ukai Exp $ */
#define MAINPROGRAM
#include "fm.h"
#include <signal.h>
@@ -4000,7 +4000,14 @@ chkURL(void)
"nntp://[a-zA-Z0-9][a-zA-Z0-9:%\\-\\./_]*",
#endif /* USE_NNTP */
"mailto:[^<> ][^<> ]*@[a-zA-Z0-9][a-zA-Z0-9\\-\\._]*[a-zA-Z0-9]",
- NULL,
+#ifdef INET6
+ "http://[a-zA-Z0-9:%\\-\\./_@]*\\[[a-fA-F0-9:][a-fA-F0-9:\\.]*\\][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*",
+#ifdef USE_SSL
+ "https://[a-zA-Z0-9:%\\-\\./_@]*\\[[a-fA-F0-9:][a-fA-F0-9:\\.]*\\][a-zA-Z0-9:%\\-\\./?=~_\\&+@#,\\$]*",
+#endif /* USE_SSL */
+ "ftp://[a-zA-Z0-9:%\\-\\./_@]*\\[[a-fA-F0-9:][a-fA-F0-9:\\.]*\\][a-zA-Z0-9:%\\-\\./=_+@#,\\$]*",
+#endif /* INET6 */
+ NULL
};
int i;
for (i = 0; url_like_pat[i]; i++) {
diff --git a/url.c b/url.c
index c8dd72c..f97aa26 100644
--- a/url.c
+++ b/url.c
@@ -1,4 +1,4 @@
-/* $Id: url.c,v 1.8 2001/11/22 13:30:02 ukai Exp $ */
+/* $Id: url.c,v 1.9 2001/11/23 20:06:40 ukai Exp $ */
#include "fm.h"
#include <sys/types.h>
#include <sys/socket.h>
@@ -384,6 +384,14 @@ openSocket(char *hostname,
}
#ifdef INET6
+ /* rfc2732 compliance */
+ if (hostname != NULL && hostname[0] == '[' &&
+ hostname[strlen(hostname)-1] == ']' ) {
+ hostname[strlen(hostname)-1] = '\0';
+ hostname++;
+ if (strspn(hostname, "0123456789abcdefABCDEF:.") != strlen(hostname))
+ goto error;
+ }
for (af = ai_family_order_table[DNS_order];; af++) {
memset(&hints, 0, sizeof(hints));
hints.ai_family = *af;
@@ -444,7 +452,7 @@ openSocket(char *hostname,
#endif
goto error;
}
- regexCompile("[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*", 0);
+ regexCompile("^[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*\\.[0-9][0-9]*$", 0);
if (regexMatch(hostname, 0, 1)) {
sscanf(hostname, "%d.%d.%d.%d", &a1, &a2, &a3, &a4);
adr = htonl((a1 << 24) | (a2 << 16) | (a3 << 8) | a4);
@@ -717,14 +725,6 @@ parseURL(char *url, ParsedURL * p_url, ParsedURL * current)
break;
}
analyze_file:
-#ifdef INET6
- /* rfc2732 compliance */
- if (p_url->host != NULL && p_url->host[0] == '[' &&
- p_url->host[strlen(p_url->host)-1] == ']' ) {
- p_url->host[strlen(p_url->host)-1] = '\0';
- ++(p_url->host);
- }
-#endif
#ifndef SUPPORT_NETBIOS_SHARE
if (p_url->scheme == SCM_LOCAL && p_url->user == NULL &&
p_url->host != NULL && strcmp(p_url->host, "localhost")) {