commit 0a71501b6430a7ade99d9f8dff911d3f91836134
parent 02a980fe2cdf5bffa01847e66b3594a155df072b
Author: ukai <ukai>
Date: Fri, 23 Nov 2001 20:06:40 +0000
[w3m-dev 02528] RFC2732 URL Patch
From: Akihiro Sagawa <sagawa@sohgoh.net>
Diffstat:
3 files changed, 26 insertions(+), 10 deletions(-)
diff --git 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
@@ -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
@@ -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")) {