From 2b98f5e7b7918155eb2b311b0d2ed938a34e4c9f Mon Sep 17 00:00:00 2001 From: Tero Saarni Date: Thu, 11 May 2023 16:32:14 +0300 Subject: [PATCH] Fix username parsing for basic auth --- gunicorn/glogging.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index 4e5fbbd5d..e5cda1967 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -469,10 +469,7 @@ def _get_user(self, environ): # so we need to convert it to a byte string auth = base64.b64decode(auth[1].strip().encode('utf-8')) # b64decode returns a byte string - auth.split(b":", 1)[0].decode("UTF-8", "replace") + user = auth.split(b":", 1)[0].decode("UTF-8") except (TypeError, binascii.Error, UnicodeDecodeError) as exc: self.debug("Couldn't get username: %s", exc) - return user - if len(auth) == 2: - user = auth[0] return user