7or8bit-decode #5

Manually merged
revsuine merged 17 commits from 7or8bit-decode into master 2024-11-14 19:45:52 +00:00
Showing only changes of commit f895e87ec0 - Show all commits

View file

@ -55,14 +55,17 @@ def decode_email(message: email.message.Message) -> email.message.Message:
:param message: email.message.Message to be decoded :param message: email.message.Message to be decoded
:return: decoded email.message.Message""" :return: decoded email.message.Message"""
payload = [] if message.is_multipart():
payload = []
for part in message.walk():
if not part.is_multipart():
payload.append(part.get_payload(decode=True))
for part in message.walk(): message.set_payload(payload)
if not part.is_multipart(): else:
payload.append(part.get_payload(decode=True)) message.set_payload(message.get_payload(decode=True))
message["Content-Transfer-Encoding"] = "7bit" message["Content-Transfer-Encoding"] = "7bit"
message.set_payload(payload)
return message return message