From ad69eb843afe10645784843f5eead9b4de503f54 Mon Sep 17 00:00:00 2001 From: Fumitoshi UKAI Date: Fri, 23 Nov 2001 20:06:40 +0000 Subject: [w3m-dev 02528] RFC2732 URL Patch From: Akihiro Sagawa --- url.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'url.c') 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 #include @@ -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")) { -- cgit v1.2.3