Compare commits
No commits in common. "6590baafd19ae3ff422dc6d4daede19d60f32d0c" and "158f5356a1b660445cfee022624e2544bb39f3a3" have entirely different histories.
6590baafd1
...
158f5356a1
1 changed files with 6 additions and 6 deletions
12
gpgmymail
12
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
|
# 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
|
# string but i couldn't get it to work any other way
|
||||||
# decoding needed:
|
# 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)
|
decoded_bytes = quopri.decodestring(decoded_bytes)
|
||||||
|
|
||||||
# replace any instances of the Content-Transfer-Encoding header
|
# 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():
|
for part in quopri_decoded_message.walk():
|
||||||
if not part.is_multipart():
|
if not part.is_multipart():
|
||||||
if part.get("Content-Transfer-Encoding") == "base64":
|
if part.get("Content-Transfer-Encoding") == "base64":
|
||||||
new_part = part
|
b64_str = part.get_payload()
|
||||||
new_part.replace_header("Content-Transfer-Encoding", "7bit")
|
decoded_b64_str = part.get_payload(decode=True)
|
||||||
new_part.set_payload(part.get_payload(decode=True))
|
|
||||||
decoded_bytes = decoded_bytes.replace(
|
decoded_bytes = decoded_bytes.replace(
|
||||||
part.as_bytes(),
|
b64_str,
|
||||||
new_part.as_bytes()
|
decoded_b64_str
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# TODO
|
# TODO
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue