This is the mail archive of the
mailing list for the Cygwin project.
Re: Double-slashes in URLs
- From: Jon TURNEY <jon dot turney at dronecode dot org dot uk>
- To: Michael Bisbjerg <michael-Ktoah55DsJR/SzgSGea1oA at public dot gmane dot org>, cygwin-apps at cygwin dot com
- Date: Tue, 22 Sep 2015 14:39:16 +0100
- Subject: Re: Double-slashes in URLs
- Authentication-results: sourceware.org; auth=none
- References: <CADhDKZsJfG5cKuqP+2mHKfbq5TYeVmksqr0sfvZNDY6m8gCZAQ at mail dot gmail dot com>
On 17/09/2015 16:18, Michael Bisbjerg wrote:
I noticed once I set up a mirror of my own, that Cygwin Setup will
prepend all it's URL's with a double-slash. This does not seem to be
intentional, and I found the place in the sources where I believe the
error to be.
On line 160 of "download.cc", we see that the "n->key" is the source
of the repository, including a "/", as it is used as the name of the
local cache, which always has a "%2f" in its name. That key is then
used on line 165 in "get_url_to_file", where it is concatenated with
another slash and "pkgsource.Canonical" to make the final URL.
This analysis seems correct. It would be nice if you went a bit further
and confirmed that the URL is always canonicalized to end with a '/'.
My (untested) patch removes this slash, so that the resulting URL's
will be with a single slash.
This looks correct, and appears to work.
In future, please try to use git format-patch, this makes it much
quicker and easier to apply the patch with the correct attribution.
------ PATCH -----
diff --git a/download.cc b/download.cc
index a5aebe0..e319ed4 100644
@@ -162,7 +162,7 @@ download_one (packagesource & pkgsource, HWND owner)
io_stream::mkpath_p (PATH_TO_FILE, "file://" + local, 0);
- if (get_url_to_file(n->key + "/" + pkgsource.Canonical (),
+ if (get_url_to_file(n->key + pkgsource.Canonical (),
local + ".tmp", pkgsource.size, owner))
/* FIXME: note new source ? */
------ PATCH -----