mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
More encoding madness
This commit is contained in:
parent
4a7a8cb7a4
commit
6c18b6f3b4
2 changed files with 4 additions and 4 deletions
|
@ -167,7 +167,7 @@ def check_output_inline(context, text):
|
||||||
out = context.stdout_capture.getvalue()
|
out = context.stdout_capture.getvalue()
|
||||||
if isinstance(out, bytes):
|
if isinstance(out, bytes):
|
||||||
out = out.decode('utf-8')
|
out = out.decode('utf-8')
|
||||||
assert text in out
|
assert text in out, text
|
||||||
|
|
||||||
|
|
||||||
@then('the output should not contain "{text}"')
|
@then('the output should not contain "{text}"')
|
||||||
|
|
|
@ -80,13 +80,13 @@ class LegacyEncryptedJournal(Journal.LegacyJournal):
|
||||||
try:
|
try:
|
||||||
plain_padded = decryptor.update(cipher) + decryptor.finalize()
|
plain_padded = decryptor.update(cipher) + decryptor.finalize()
|
||||||
self.config['password'] = password
|
self.config['password'] = password
|
||||||
if plain_padded[-1] == " ":
|
if plain_padded[-1] in (" ", 32):
|
||||||
# Ancient versions of jrnl. Do not judge me.
|
# Ancient versions of jrnl. Do not judge me.
|
||||||
plain = plain_padded.rstrip(" ")
|
return plain_padded.decode('utf-8').rstrip(" ")
|
||||||
else:
|
else:
|
||||||
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
|
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
|
||||||
plain = unpadder.update(plain_padded) + unpadder.finalize()
|
plain = unpadder.update(plain_padded) + unpadder.finalize()
|
||||||
return plain.decode('utf-8')
|
return plain.decode('utf-8')
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
if password:
|
if password:
|
||||||
|
|
Loading…
Add table
Reference in a new issue