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
This commit is contained in:
Ben Busby 2023-05-19 11:37:50 -06:00
parent 2cb4b9e3ca
commit f213a2a64a
No known key found for this signature in database
GPG Key ID: B9B7231E01D924A1

View File

@ -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 = {}