summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kuhn <michael.kuhn@ovgu.de>2021-05-19 00:26:49 +0200
committerGitHub <noreply@github.com>2021-05-18 15:26:49 -0700
commit9410d991539ec14b4159273b3dc94aac0045f993 (patch)
treecff747868941fd959024e748e2326594ba00b4d1
parentba68cbc6943f3cb98d6988eeff54f4976218ad9d (diff)
downloadspack-9410d991539ec14b4159273b3dc94aac0045f993.tar.gz
spack-9410d991539ec14b4159273b3dc94aac0045f993.tar.bz2
spack-9410d991539ec14b4159273b3dc94aac0045f993.tar.xz
spack-9410d991539ec14b4159273b3dc94aac0045f993.zip
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).
-rw-r--r--lib/spack/spack/fetch_strategy.py10
1 files changed, 9 insertions, 1 deletions
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):