From f213a2a64ac05570f4b70b795c7a52476fe31516 Mon Sep 17 00:00:00 2001 From: Ben Busby Date: Fri, 19 May 2023 11:37:50 -0600 Subject: [PATCH] Ensure b64 prefs always have min padding This relates to an issue with an unknown cause (unable to reproduce on my end) where the preferences string does not contain the correct amount of padding on a base64 encoded value. This is mediated by appending padding to the end of the encoded value, since any extra padding is removed anyways. Fixes #987 --- app/models/config.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/models/config.py b/app/models/config.py index f6ca884..9ab11cd 100644 --- a/app/models/config.py +++ b/app/models/config.py @@ -254,7 +254,8 @@ class Config: key = self._get_fernet_key(self.preferences_key) config = Fernet(key).decrypt( - brotli.decompress(urlsafe_b64decode(preferences.encode())) + brotli.decompress(urlsafe_b64decode( + preferences.encode() + b'==')) ) config = pickle.loads(brotli.decompress(config)) @@ -262,7 +263,8 @@ class Config: config = {} elif mode == 'u': # preferences are not encrypted config = pickle.loads( - brotli.decompress(urlsafe_b64decode(preferences.encode())) + brotli.decompress(urlsafe_b64decode( + preferences.encode() + b'==')) ) else: # preferences are incorrectly formatted config = {}