use utf-8 encoding for gpg encryption

This commit is contained in:
revsuine 2024-11-04 23:55:56 +00:00
parent 3338035673
commit 51c0ea34a7
Signed by: revsuine
GPG key ID: 3F257B68F5BC9339

View file

@ -68,7 +68,9 @@ def encrypt(
if is_message_encrypted(message) and not unconditionally_encrypt: if is_message_encrypted(message) and not unconditionally_encrypt:
return message.as_string() return message.as_string()
encrypted_content = gnupg.GPG().encrypt(message.as_string(), recipients, armor=True) gpg = gnupg.GPG()
gpg.encoding = 'utf-8' # default is latin-1 which fails w some unicode chars
encrypted_content = gpg.encrypt(message.as_string(), recipients, armor=True)
if not encrypted_content: if not encrypted_content:
raise ValueError(encrypted_content.status) raise ValueError(encrypted_content.status)