GNU bug report logs - #49483
[PATCH 2/3] substitutes: Properly construct URLs.

Previous Next

Package: guix-patches;

Reported by: Hartmut Goebel <h.goebel <at> crazy-compilers.com>

Date: Fri, 9 Jul 2021 08:39:02 UTC

Severity: normal

Tags: patch

Done: Hartmut Goebel <h.goebel <at> goebel-consult.de>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49483 in the body.
You can then email your comments to 49483 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49483; Package guix-patches. (Fri, 09 Jul 2021 08:39:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Hartmut Goebel <h.goebel <at> crazy-compilers.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 09 Jul 2021 08:39:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Hartmut Goebel <h.goebel <at> crazy-compilers.com>
To: 44906 <at> debbugs.gnu.org,
	guix-patches <at> gnu.org
Subject: [PATCH 2/3] substitutes: Properly construct URLs.
Date: Fri,  9 Jul 2021 10:38:39 +0200
Use relative URIs and "resolve-uri-reference" (which implements the algorithm
specified in RFC 3986 section 5.2.2) for building the URL, instead of just
appending strings. This avoids issued if the cache-url ends with a slash.

* guix/substitutes.scm (narinfo-request): Use resolve-uri-reference for
  constructing the url.
---
 guix/substitutes.scm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index 4987cda165..a5c554acff 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -37,7 +37,8 @@
   #:use-module ((guix build utils) #:select (mkdir-p dump-port))
   #:use-module ((guix build download)
                 #:select ((open-connection-for-uri
-                           . guix:open-connection-for-uri)))
+                           . guix:open-connection-for-uri)
+                          resolve-uri-reference))
   #:use-module (guix progress)
   #:use-module (ice-9 rdelim)
   #:use-module (ice-9 regex)
@@ -155,10 +156,12 @@ indicates that PATH is unavailable at CACHE-URL."
 
 (define (narinfo-request cache-url path)
   "Return an HTTP request for the narinfo of PATH at CACHE-URL."
-  (let ((url (string-append cache-url "/" (store-path-hash-part path)
-                            ".narinfo"))
-        (headers '((User-Agent . "GNU Guile"))))
-    (build-request (string->uri url) #:method 'GET #:headers headers)))
+  (let* ((base (string->uri cache-url))
+         (ref (build-relative-ref
+               #:path (string-append (store-path-hash-part path) ".narinfo")))
+         (url (resolve-uri-reference ref base))
+         (headers '((User-Agent . "GNU Guile"))))
+    (build-request url #:method 'GET #:headers headers)))
 
 (define (narinfo-from-file file url)
   "Attempt to read a narinfo from FILE, using URL as the cache URL.  Return #f
-- 
2.30.2





bug closed, send any further explanations to 49483 <at> debbugs.gnu.org and Hartmut Goebel <h.goebel <at> crazy-compilers.com> Request was from Hartmut Goebel <h.goebel <at> goebel-consult.de> to control <at> debbugs.gnu.org. (Fri, 16 Jul 2021 18:02:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 14 Aug 2021 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 255 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.