]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[utils] Check for None values in SOCKS proxy
authorYen Chi Hsuan <yan12125@gmail.com>
Tue, 17 May 2016 06:38:15 +0000 (14:38 +0800)
committerYen Chi Hsuan <yan12125@gmail.com>
Tue, 17 May 2016 06:38:15 +0000 (14:38 +0800)
Originally reported at
https://github.com/rg3/youtube-dl/pull/9287#issuecomment-219617864

youtube_dl/utils.py

index 24e74428b03b4a532aeadd0a0292bb8023d17473..ac60ba18cd9fd9c5ecba155af3752458d0729766 100644 (file)
@@ -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):