aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/utils/networking.py
diff options
context:
space:
mode:
authorcoletdjnz <coletdjnz@protonmail.com>2023-07-28 02:56:02 +1200
committerGitHub <noreply@github.com>2023-07-27 20:26:02 +0530
commitbbeacff7fcaa3b521066088a5ccbf34ef5070d1d (patch)
tree7cb66eb3b93374fe7e2629f94900cb2a183fdd8b /yt_dlp/utils/networking.py
parentdae349da97cafe7357106a8f3187fd48a2ad1210 (diff)
downloadhypervideo-pre-bbeacff7fcaa3b521066088a5ccbf34ef5070d1d.tar.lz
hypervideo-pre-bbeacff7fcaa3b521066088a5ccbf34ef5070d1d.tar.xz
hypervideo-pre-bbeacff7fcaa3b521066088a5ccbf34ef5070d1d.zip
[networking] Ignore invalid proxies in env (#7704)
Authored by: coletdjnz
Diffstat (limited to 'yt_dlp/utils/networking.py')
-rw-r--r--yt_dlp/utils/networking.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/yt_dlp/utils/networking.py b/yt_dlp/utils/networking.py
index ac355ddc8..e6515ec8e 100644
--- a/yt_dlp/utils/networking.py
+++ b/yt_dlp/utils/networking.py
@@ -98,7 +98,13 @@ def clean_proxies(proxies: dict, headers: HTTPHeaderDict):
continue
if proxy_url is not None:
# Ensure proxies without a scheme are http.
- proxy_scheme = urllib.request._parse_proxy(proxy_url)[0]
+ try:
+ proxy_scheme = urllib.request._parse_proxy(proxy_url)[0]
+ except ValueError:
+ # Ignore invalid proxy URLs. Sometimes these may be introduced through environment
+ # variables unrelated to proxy settings - e.g. Colab `COLAB_LANGUAGE_SERVER_PROXY`.
+ # If the proxy is going to be used, the Request Handler proxy validation will handle it.
+ continue
if proxy_scheme is None:
proxies[proxy_key] = 'http://' + remove_start(proxy_url, '//')