[PATCH] Escape percent-signs in portage.package.ebuild.fetch.get_mirror_url()

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH] Escape percent-signs in portage.package.ebuild.fetch.get_mirror_url()

Mike Gilbert-2
This avoids double-escaping in emirrordist. We only want to escape the
path when fetching the file from the mirror, not when mirroring the
file.

Bug: https://bugs.gentoo.org/719810
Fixes: 4c18f523bb86a8be4c148f365dabee06fca2e4fa
Signed-off-by: Mike Gilbert <[hidden email]>
---
 lib/portage/package/ebuild/fetch.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py
index 28e7caf53..9682fea89 100644
--- a/lib/portage/package/ebuild/fetch.py
+++ b/lib/portage/package/ebuild/fetch.py
@@ -26,6 +26,11 @@ try:
 except ImportError:
  from urlparse import urlparse
 
+try:
+ from urllib.parse import quote as urlquote
+except ImportError:
+ from urllib import quote as urlquote
+
 import portage
 portage.proxy.lazyimport.lazyimport(globals(),
  'portage.package.ebuild.config:check_config_instance,config',
@@ -520,7 +525,7 @@ def get_mirror_url(mirror_url, filename, mysettings, cache_path=None):
  f.close()
 
  return (mirror_url + "/distfiles/" +
- mirror_conf.get_best_supported_layout().get_path(filename))
+ urlquote(mirror_conf.get_best_supported_layout().get_path(filename)))
 
 
 def fetch(myuris, mysettings, listonly=0, fetchonly=0,
--
2.27.0.rc2


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] Escape percent-signs in portage.package.ebuild.fetch.get_mirror_url()

Zac Medico-2
On 5/31/20 2:32 PM, Mike Gilbert wrote:

> This avoids double-escaping in emirrordist. We only want to escape the
> path when fetching the file from the mirror, not when mirroring the
> file.
>
> Bug: https://bugs.gentoo.org/719810
> Fixes: 4c18f523bb86a8be4c148f365dabee06fca2e4fa
> Signed-off-by: Mike Gilbert <[hidden email]>
> ---
>  lib/portage/package/ebuild/fetch.py | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/lib/portage/package/ebuild/fetch.py b/lib/portage/package/ebuild/fetch.py
> index 28e7caf53..9682fea89 100644
> --- a/lib/portage/package/ebuild/fetch.py
> +++ b/lib/portage/package/ebuild/fetch.py
> @@ -26,6 +26,11 @@ try:
>  except ImportError:
>   from urlparse import urlparse
>  
> +try:
> + from urllib.parse import quote as urlquote
> +except ImportError:
> + from urllib import quote as urlquote
> +
>  import portage
>  portage.proxy.lazyimport.lazyimport(globals(),
>   'portage.package.ebuild.config:check_config_instance,config',
> @@ -520,7 +525,7 @@ def get_mirror_url(mirror_url, filename, mysettings, cache_path=None):
>   f.close()
>  
>   return (mirror_url + "/distfiles/" +
> - mirror_conf.get_best_supported_layout().get_path(filename))
> + urlquote(mirror_conf.get_best_supported_layout().get_path(filename)))
>  
>  
>  def fetch(myuris, mysettings, listonly=0, fetchonly=0,
>
Looks good. Please merge.
--
Thanks,
Zac


signature.asc (1000 bytes) Download Attachment