Merge pull request #404 from ThomasWaldmann/basic-auth-exception

catch exception for invalid http basic auth strings, fixes #401
This commit is contained in:
TW 2019-04-04 00:55:44 +02:00 committed by GitHub
commit 282b1786ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,11 @@ def basic_authenticate(auth):
:return: username, password [unicode on py2, str on py3]
"""
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':
return
# we ignore bytes that do not decode. username (hostname) and password