catch exception for invalid http basic auth strings, fixes #401

This commit is contained in:
Thomas Waldmann 2019-04-04 00:13:34 +02:00
parent 53cf7ee6dd
commit 1a8192b4bc

View File

@ -119,7 +119,11 @@ def basic_authenticate(auth):
:return: username, password [unicode on py2, str on py3] :return: username, password [unicode on py2, str on py3]
""" """
assert isinstance(auth, str) assert isinstance(auth, str)
authmeth, auth = auth.split(' ', 1) try:
authmeth, auth = auth.split(' ', 1)
except ValueError:
# splitting failed, invalid auth string
return
if authmeth.lower() != 'basic': if authmeth.lower() != 'basic':
return return
# we ignore bytes that do not decode. username (hostname) and password # we ignore bytes that do not decode. username (hostname) and password