This commit is contained in:
revsuine 2024-11-14 19:51:56 +00:00
parent c148b94be1
commit 8fea330537
Signed by: revsuine
GPG key ID: 3F257B68F5BC9339

View file

@ -83,6 +83,19 @@ def decode_email(message: email.message.Message) -> email.message.Message:
decoded_bytes: bytes, decoded_bytes: bytes,
most_recent_boundary: str = None most_recent_boundary: str = None
) -> bytes: ) -> bytes:
"""
change decoded_bytes such that part is decoded if base64 (unchanged if
not)
see usage below for examples
:param part: email.message.Message to be decoded
:param decoded_bytes: the email as a bytes object (ie not a string with
encoding), will have modified version returned
:param most_recent_boundary: str of the most recent boundary so we
don't overwrite this
:return: bytes of decoded_bytes with part decoded if base64
"""
if part.get("Content-Transfer-Encoding") == "base64": if part.get("Content-Transfer-Encoding") == "base64":
b64_str = part.get_payload() b64_str = part.get_payload()
# remove the boundary as we don't want to change this # remove the boundary as we don't want to change this