7or8bit-decode #5
1 changed files with 5 additions and 3 deletions
|
@ -61,7 +61,7 @@ def decode_email(message: email.message.Message) -> email.message.Message:
|
||||||
# string but i couldn't get it to work any other way
|
# string but i couldn't get it to work any other way
|
||||||
# decoding needed:
|
# decoding needed:
|
||||||
# as_string() gives us str, encode() gives us bytes
|
# as_string() gives us str, encode() gives us bytes
|
||||||
decoded_bytes = message.as_string().encode()
|
decoded_bytes = message.as_bytes()
|
||||||
decoded_bytes = quopri.decodestring(decoded_bytes)
|
decoded_bytes = quopri.decodestring(decoded_bytes)
|
||||||
|
|
||||||
# replace any instances of the Content-Transfer-Encoding header
|
# replace any instances of the Content-Transfer-Encoding header
|
||||||
|
@ -109,7 +109,9 @@ def decode_email(message: email.message.Message) -> email.message.Message:
|
||||||
b'Content-Transfer-Encoding: 7bit'
|
b'Content-Transfer-Encoding: 7bit'
|
||||||
)
|
)
|
||||||
|
|
||||||
return email.message_from_bytes(decoded_bytes)
|
# if i do message_from_bytes it bizarrely changes it back to base64?
|
||||||
|
# utf-8 has encoding issues so do latin1
|
||||||
|
return email.message_from_string(decoded_bytes.decode("latin1"))
|
||||||
|
|
||||||
def encrypt(
|
def encrypt(
|
||||||
message: email.message.Message,
|
message: email.message.Message,
|
||||||
|
|
Loading…
Reference in a new issue