From a7ead9831e3c43826ce40e01ba4e8c36b9e12644 Mon Sep 17 00:00:00 2001 From: Benoit Chesneau Date: Sun, 7 May 2023 21:05:41 +0200 Subject: [PATCH] fix basic auth logging decoding of basic auth header. fix #2625 --- gunicorn/glogging.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gunicorn/glogging.py b/gunicorn/glogging.py index e614294d..60745f98 100644 --- a/gunicorn/glogging.py +++ b/gunicorn/glogging.py @@ -469,8 +469,7 @@ class Logger(object): # 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 = auth.decode('utf-8') - auth = auth.split(":", 1) + auth.split(b":", 1)[0].decode(UTF-8", "replace") except (TypeError, binascii.Error, UnicodeDecodeError) as exc: self.debug("Couldn't get username: %s", exc) return user