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):
if upload_date is None:
timetuple = email.utils.parsedate_tz(date_str)
if timetuple:
- upload_date = datetime.datetime(*timetuple[:6]).strftime('%Y%m%d')
+ try:
+ upload_date = datetime.datetime(*timetuple[:6]).strftime('%Y%m%d')
+ except ValueError:
+ pass
if upload_date is not None:
return compat_str(upload_date)
def remove_start(s, start):
- if s.startswith(start):
- return s[len(start):]
- return s
+ return s[len(start):] if s is not None and s.startswith(start) else s
def remove_end(s, end):
- if s.endswith(end):
- return s[:-len(end)]
- return s
+ return s[:-len(end)] if s is not None and s.endswith(end) else s
def remove_quotes(s):