From owner-freebsd-ports Wed May 5 3:10: 7 1999 Delivered-To: freebsd-ports@freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.ORG [204.216.27.21]) by hub.freebsd.org (Postfix) with ESMTP id 14A31158BE for ; Wed, 5 May 1999 03:10:02 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.9.3/8.9.2) id DAA02215; Wed, 5 May 1999 03:10:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from apollon.greg.rim.or.jp (t154.cablecom.ne.jp [202.248.199.154]) by hub.freebsd.org (Postfix) with ESMTP id 0B94B1554D for ; Wed, 5 May 1999 03:02:27 -0700 (PDT) (envelope-from greg@greg.rim.or.jp) Received: from izanami.greg.rim.or.jp (greg@izanami.greg.rim.or.jp [172.31.1.3]) by apollon.greg.rim.or.jp (8.9.3/3.7W) with ESMTP id TAA46477 for ; Wed, 5 May 1999 19:02:26 +0900 (JST) Received: (from greg@localhost) by izanami.greg.rim.or.jp (8.9.3/3.4Wbeta6) id TAA57846; Wed, 5 May 1999 19:02:26 +0900 (JST) Message-Id: <199905051002.TAA57846@izanami.greg.rim.or.jp> Date: Wed, 5 May 1999 19:02:26 +0900 (JST) From: greg@greg.rim.or.jp Reply-To: greg@greg.rim.or.jp To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: ports/11509: Can not rewrite collectly in wget mirror function Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 11509 >Category: ports >Synopsis: Can not rewrite collectly in wget mirror function >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed May 5 03:10:01 PDT 1999 >Closed-Date: >Last-Modified: >Originator: Kensaku Masuda >Release: FreeBSD 3.1-STABLE i386 >Organization: >Environment: Not specified. >Description: wget can not rewrite a relative link collectly. For example. Base URI is "http://www.foo.com/~bar" and link is "../%7Ebar/some/sone.html". wget must rewrite a link like this, "../%257Ebar/some/sone.html" or "some/sone.html". But wget not. >How-To-Repeat: Do mirror that have relative links include "../%7E" >Fix: I create a fix and reported into wget maintener. --- src.orig/url.c Wed May 5 15:12:38 1999 +++ src/url.c Wed May 5 15:29:32 1999 @@ -1335,6 +1335,24 @@ strncat (constr + i, sub, subsize); constr[i + subsize] = '\0'; } /* *sub == `/' */ + { + int len, current; + len = strlen(constr); + current = 0; + for(i = 0 ; i < len ; i++, current++) { + if(strncmp(constr + i, "/../", 4) == 0) { + i += 4; + for(current--; current > 0 ; current--) { + if(constr[current] == '/') { + current++; + break; + } + } + } + constr[current] = constr[i]; + } + constr[current] = 0; + } } else /* !no_proto */ { @@ -1390,6 +1408,7 @@ FILE *fp; char *buf, *p, *p2; long size; + int i; logprintf (LOG_VERBOSE, _("Converting %s... "), file); /* Read from the file.... */ @@ -1422,25 +1441,46 @@ /* If the URL already is relative or it is not to be converted for some other reason (e.g. because of not having been downloaded in the first place), skip it. */ - if ((l->flags & URELATIVE) || !(l->flags & UABS2REL)) - { - DEBUGP (("Skipping %s at position %d (flags %d).\n", l->url, - l->pos, l->flags)); - continue; - } + if((l->flags & UABS2REL) == 0) { + DEBUGP (("Skipping %s at position %d (flags %d).\n", l->url, + l->pos, l->flags)); + + continue; + } /* Else, reach the position of the offending URL, echoing everything up to it to the outfile. */ for (p2 = buf + l->pos; p < p2; p++) putc (*p, fp); - if (l->flags & UABS2REL) - { - char *newname = construct_relative (file, l->local_name); - char *collect = construct_escape(newname); + if(l->local_name != NULL) { + char *newname; + char *collect; + + newname = construct_relative (file, l->local_name); + collect = construct_escape(newname); fprintf (fp, "%s", collect); DEBUGP (("ABS2REL: %s to %s at position %d in %s.\n", l->url, newname, l->pos, file)); free (newname); free (collect); + } else { + struct urlinfo *url = newurl(); + char *collect; + char *newname; + + parseurl(l->url, url, 0); + l->local_name = url_filename(url); + newname = construct_escape(file); + collect = construct_relative (newname, l->local_name); + free(l->local_name); + l->local_name = NULL; + + fprintf (fp, "%s", collect); + DEBUGP (("ABS2REL: %s to %s at position %d in %s.\n", + l->url, collect, l->pos, file)); + free (collect); + free (newname); + + freeurl(url, 1); } p += l->size; } >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message