public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* Double-slashes in URLs
@ 2015-09-17 15:18 Michael Bisbjerg
  2015-09-22 13:39 ` Jon TURNEY
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Bisbjerg @ 2015-09-17 15:18 UTC (permalink / raw)
  To: cygwin-apps

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.

My (untested) patch removes this slash, so that the resulting URL's
will be with a single slash.

------ PATCH -----
diff --git a/download.cc b/download.cc
index a5aebe0..e319ed4 100644
--- a/download.cc
+++ b/download.cc
@@ -162,7 +162,7 @@ download_one (packagesource & pkgsource, HWND owner)
                                  pkgsource.Canonical ();
       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 -----

Regards.
Michael

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Double-slashes in URLs
  2015-09-17 15:18 Double-slashes in URLs Michael Bisbjerg
@ 2015-09-22 13:39 ` Jon TURNEY
  2015-10-19 15:44   ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Jon TURNEY @ 2015-09-22 13:39 UTC (permalink / raw)
  To: Michael Bisbjerg, cygwin-apps

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.

Thanks.

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
> --- a/download.cc
> +++ b/download.cc
> @@ -162,7 +162,7 @@ download_one (packagesource & pkgsource, HWND owner)
>                                    pkgsource.Canonical ();
>         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 -----

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Double-slashes in URLs
  2015-09-22 13:39 ` Jon TURNEY
@ 2015-10-19 15:44   ` Corinna Vinschen
  0 siblings, 0 replies; 3+ messages in thread
From: Corinna Vinschen @ 2015-10-19 15:44 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 1268 bytes --]

On Sep 22 14:39, Jon TURNEY wrote:
> 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.
> 
> Thanks.
> 
> This looks correct, and appears to work.

Thanks for your patch, Michael!

Jon, did you apply this patch?  If not, feel free to do so.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat

[-- Attachment #2: Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-10-19 15:44 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-17 15:18 Double-slashes in URLs Michael Bisbjerg
2015-09-22 13:39 ` Jon TURNEY
2015-10-19 15:44   ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).