--- src/url.c.orig	Wed Nov 11 19:04:27 1998
+++ src/url.c	Wed Nov 11 18:57:52 1998
@@ -143,6 +143,7 @@
 static uerr_t parse_uname PARAMS ((const char *, char **, char **));
 static char *construct PARAMS ((const char *, const char *, int , int));
 static char *construct_relative PARAMS ((const char *, const char *));
+static char *construct_escape PARAMS ((const char *path));
 static char process_ftp_type PARAMS ((char *));
 
 
@@ -1414,10 +1415,12 @@
       if (l->flags & UABS2REL)
 	{
 	  char *newname = construct_relative (file, l->local_name);
-	  fprintf (fp, "%s", newname);
+	  char *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);
 	}
       p += l->size;
     }
@@ -1429,6 +1432,32 @@
   fclose (fp);
   free (buf);
   logputs (LOG_VERBOSE, _("done.\n"));
+}
+
+/*
+ */
+static char * construct_escape(const char *path)
+{
+	unsigned int	length = strlen(path);
+	unsigned int	i, offset;
+	char *		string = NULL;
+
+	for(i = 0 ; path[i] != 0 ; i++) {
+		if(path[i] == '%') {
+			length += 2;
+		}
+	}
+	string = xmalloc(length + 1);
+	for(i = 0, offset = 0 ; path[i] != 0 ; i++, offset++) {
+		string[offset] = path[i];
+		if(path[i] == '%') {
+			string[offset + 1] = '2';
+			string[offset + 2] = '5';
+			offset += 2;
+		}
+	}
+	string[offset] = 0;
+	return string;
 }
 
 /* Construct and return a malloced copy of the relative link from two
