1 |
commit: 20b6a36fbf791bcc7d42bd429cf8116399a014a7 |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Sep 12 21:23:28 2020 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Sep 12 22:08:45 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=20b6a36f |
7 |
|
8 |
get_mirror_url: urlquote only for ftp, http, and https (bug 741474) |
9 |
|
10 |
It's necessary to use urlquote for correct behavior with ftp, http, |
11 |
and https, since it's possible for file names to contain percent |
12 |
encoded characters that need to be protected by an additional layer |
13 |
of percent encoding. For other protocols such as sftp and rsync, |
14 |
all characters are interpreted literally, so urlquote must not be |
15 |
used. |
16 |
|
17 |
Fixes: c238d5f7ed264179c263f5a2da983c4ee50b4f00 |
18 |
Bug: https://bugs.gentoo.org/719810 |
19 |
Bug: https://bugs.gentoo.org/741474 |
20 |
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org> |
21 |
|
22 |
lib/portage/package/ebuild/fetch.py | 8 ++++++-- |
23 |
1 file changed, 6 insertions(+), 2 deletions(-) |
24 |
|
25 |
diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py |
26 |
index 7c61fe463..ca031f31e 100644 |
27 |
--- a/lib/portage/package/ebuild/fetch.py |
28 |
+++ b/lib/portage/package/ebuild/fetch.py |
29 |
@@ -513,8 +513,12 @@ def get_mirror_url(mirror_url, filename, mysettings, cache_path=None): |
30 |
json.dump(cache, f) |
31 |
f.close() |
32 |
|
33 |
- return (mirror_url + "/distfiles/" + |
34 |
- urlquote(mirror_conf.get_best_supported_layout().get_path(filename))) |
35 |
+ # For some protocols, urlquote is required for correct behavior, |
36 |
+ # and it must not be used for other protocols like rsync and sftp. |
37 |
+ path = mirror_conf.get_best_supported_layout().get_path(filename) |
38 |
+ if urlparse(mirror_url).scheme in ('ftp', 'http', 'https'): |
39 |
+ path = urlquote(path) |
40 |
+ return mirror_url + "/distfiles/" + path |
41 |
|
42 |
|
43 |
def fetch(myuris, mysettings, listonly=0, fetchonly=0, |