From eaad34fefd44d70c0f2764c398ffb04b3b57e263 Mon Sep 17 00:00:00 2001 From: Daniel Mach Date: Thu, 20 Jul 2023 09:07:43 +0200 Subject: [PATCH] Fix crash when HTTP_PROXY env contains no auth --- osc/connection.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/osc/connection.py b/osc/connection.py index f6580809a8..ed880103d8 100644 --- a/osc/connection.py +++ b/osc/connection.py @@ -107,10 +107,11 @@ def get_proxy_manager(env): user_agent=f"osc/{__version__}", ) - proxy_basic_auth = urllib.parse.unquote(proxy_purl.auth) - proxy_basic_auth = proxy_basic_auth.encode("utf-8") - proxy_basic_auth = base64.b64encode(proxy_basic_auth).decode() - proxy_headers["Proxy-Authorization"] = f"Basic {proxy_basic_auth:s}" + if proxy_purl.auth: + proxy_basic_auth = urllib.parse.unquote(proxy_purl.auth) + proxy_basic_auth = proxy_basic_auth.encode("utf-8") + proxy_basic_auth = base64.b64encode(proxy_basic_auth).decode() + proxy_headers["Proxy-Authorization"] = f"Basic {proxy_basic_auth:s}" manager = urllib3.ProxyManager(proxy_url, proxy_headers=proxy_headers) return manager