--- src/url.c.orig	Sat May  8 22:28:11 1999
+++ src/url.c	Sat May  8 22:28:12 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;
     }
