diff --git a/gpgmymail b/gpgmymail index 41f6813..1d23a23 100755 --- a/gpgmymail +++ b/gpgmymail @@ -60,7 +60,8 @@ def decode_email(message: email.message.Message) -> email.message.Message: # this is a kinda hacky way to do this by manipulating the message as a # string but i couldn't get it to work any other way # decoding needed: - decoded_bytes = message.as_bytes() + # as_string() gives us str, encode() gives us bytes + decoded_bytes = message.as_string().encode() decoded_bytes = quopri.decodestring(decoded_bytes) # replace any instances of the Content-Transfer-Encoding header @@ -81,12 +82,11 @@ def decode_email(message: email.message.Message) -> email.message.Message: for part in quopri_decoded_message.walk(): if not part.is_multipart(): if part.get("Content-Transfer-Encoding") == "base64": - new_part = part - new_part.replace_header("Content-Transfer-Encoding", "7bit") - new_part.set_payload(part.get_payload(decode=True)) + b64_str = part.get_payload() + decoded_b64_str = part.get_payload(decode=True) decoded_bytes = decoded_bytes.replace( - part.as_bytes(), - new_part.as_bytes() + b64_str, + decoded_b64_str ) else: # TODO