$NetBSD: patch-bc,v 1.5 2000/02/16 00:24:41 itohy Exp $ --- misc.c.orig Sun Dec 19 01:07:01 1999 +++ misc.c Wed Feb 16 07:49:26 2000 @@ -44,7 +44,7 @@ URL *Url=(URL*)malloc(sizeof(URL)); char *copyurl,*mallocurl=malloc(strlen(url)+2); int i=0,n=0; - char *colon,*slash,*at,*ques,*temppath,root[2]; + char *colon,*slash,*escr,*at,*ques,*temppath,root[2]; copyurl=mallocurl; strcpy(copyurl,url); @@ -175,12 +175,17 @@ strcpy(Url->host,copyurl); } - for(i=0;Url->host[i] && Url->host[i]!=':';i++) + colon=strrchr(Url->host,':'); + escr=strrchr(Url->host,']'); + if (escr && colon < escr) + colon = strrchr(escr+1,':'); + + for(i=0;Url->host[i] && (i != colon - Url->host);i++) Url->host[i]=tolower(Url->host[i]); - if(Url->host[i]==':') - if(atoi(&Url->host[i+1])==(Url->Protocol?Url->Protocol->defport:80)) - Url->host[i]=0; + if(colon) + if(atoi(colon+1)==(Url->Protocol?Url->Protocol->defport:80)) + *colon=0; if(!Url->local && IsLocalHost(Url->host,1) && Url->Protocol && Url->Protocol==&Protocols[0]) {