Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 5 May 1999 19:02:26 +0900 (JST)
From:      greg@greg.rim.or.jp
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   ports/11509: Can not rewrite collectly in wget mirror function
Message-ID:  <199905051002.TAA57846@izanami.greg.rim.or.jp>

next in thread | raw e-mail | index | archive | help

>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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199905051002.TAA57846>