From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 39937 invoked by alias); 22 Sep 2015 13:39:27 -0000 Mailing-List: contact cygwin-apps-help@cygwin.com; run by ezmlm Precedence: bulk Sender: cygwin-apps-owner@cygwin.com List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps@cygwin.com Received: (qmail 39923 invoked by uid 89); 22 Sep 2015 13:39:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: out1-smtp.messagingengine.com Received: from out1-smtp.messagingengine.com (HELO out1-smtp.messagingengine.com) (66.111.4.25) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 22 Sep 2015 13:39:25 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 5E7D6207AF for ; Tue, 22 Sep 2015 09:39:23 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Tue, 22 Sep 2015 09:39:23 -0400 Received: from [192.168.1.102] (host86-160-189-124.range86-160.btcentralplus.com [86.160.189.124]) by mail.messagingengine.com (Postfix) with ESMTPA id DE4D9C00016; Tue, 22 Sep 2015 09:39:22 -0400 (EDT) Subject: Re: Double-slashes in URLs To: Michael Bisbjerg , cygwin-apps@cygwin.com References: From: Jon TURNEY Message-ID: <56015A04.70306@dronecode.org.uk> Date: Tue, 22 Sep 2015 13:39:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2015-09/txt/msg00033.txt.bz2 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 -----