From ee6aad5d0acb8a785502d9af9b91865826991cf1 Mon Sep 17 00:00:00 2001 From: pdxlocations <117498748+pdxlocations@users.noreply.github.com> Date: Sun, 18 May 2025 16:57:49 -0700 Subject: [PATCH] allow blank key (#178) --- contact/utilities/input_handlers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/contact/utilities/input_handlers.py b/contact/utilities/input_handlers.py index 6a0497d..a4b3994 100644 --- a/contact/utilities/input_handlers.py +++ b/contact/utilities/input_handlers.py @@ -104,11 +104,13 @@ def get_admin_key_input(current_value: List[bytes]) -> Optional[List[str]]: return [base64.b64encode(b).decode() for b in byte_strings] def is_valid_base64(s): - """Check if a string is valid Base64.""" + """Check if a string is valid Base64 or blank.""" + if s == "": + return True try: decoded = base64.b64decode(s, validate=True) return len(decoded) == 32 # Ensure it's exactly 32 bytes - except binascii.Error: + except (binascii.Error, ValueError): return False cvalue = to_base64(current_value) # Convert current values to Base64