From 9410d991539ec14b4159273b3dc94aac0045f993 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Wed, 19 May 2021 00:26:49 +0200 Subject: Bugfix: fetching oddly-named resources from local mirrors (#23300) Spack uses curl to fetch URL resources. For locally-stored resources it uses curl's file protocol; when using this protocol, curl expects that the URL encoding conforms to RFC 3986 (which reserves characters like '?' and '=' for special use). We were not performing this encoding, and found a resource where curl was interpreting this in an unfavorable way (succeeding, but producing an empty file). This commit properly encodes URLs when using curl's file protocol. This error did not likely come up before because in most contexts Spack was either fetching via http or it was using URLs without offending characters (for example, the sha-based URLs in mirrors never contain these characters). --- lib/spack/spack/fetch_strategy.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/spack/spack/fetch_strategy.py b/lib/spack/spack/fetch_strategy.py index b5ce8495e3..f885980ccd 100644 --- a/lib/spack/spack/fetch_strategy.py +++ b/lib/spack/spack/fetch_strategy.py @@ -292,7 +292,15 @@ class URLFetchStrategy(FetchStrategy): @property def candidate_urls(self): - return [self.url] + (self.mirrors or []) + urls = [] + + for url in [self.url] + (self.mirrors or []): + if url.startswith('file://'): + path = urllib_parse.quote(url[len('file://'):]) + url = 'file://' + path + urls.append(url) + + return urls @_needs_stage def fetch(self): -- cgit v1.2.3-60-g2f50