aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-05-17 14:38:15 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-05-17 14:38:15 +0800
commitcdd94c2eae6c6f0a627d457c3a73894a62eb86c5 (patch)
tree7edc593826ce3db121213f895c16c36278368d72
parent36755d9d694f818ce8f367ce7eb41374f194893d (diff)
[utils] Check for None values in SOCKS proxy
Originally reported at https://github.com/rg3/youtube-dl/pull/9287#issuecomment-219617864
-rw-r--r--youtube_dl/utils.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 24e74428b..ac60ba18c 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -883,12 +883,17 @@ def make_socks_conn_class(base_class, socks_proxy):
elif url_components.scheme.lower() == 'socks4a':
socks_type = ProxyType.SOCKS4A
+ def unquote_if_non_empty(s):
+ if not s:
+ return s
+ return compat_urllib_parse_unquote_plus(s)
+
proxy_args = (
socks_type,
url_components.hostname, url_components.port or 1080,
True, # Remote DNS
- compat_urllib_parse_unquote_plus(url_components.username),
- compat_urllib_parse_unquote_plus(url_components.password),
+ unquote_if_non_empty(url_components.username),
+ unquote_if_non_empty(url_components.password),
)
class SocksConnection(base_class):