From da1f599b349df29869f3e373f6d9a0d03171e8e2 Mon Sep 17 00:00:00 2001 From: Vladimir-A <32281993+Vladimir-A@users.noreply.github.com> Date: Sat, 23 Nov 2024 15:44:23 +0300 Subject: [PATCH] Add /png type Improved data URI scheme, add /png type --- extract_msg/msg_classes/message_base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extract_msg/msg_classes/message_base.py b/extract_msg/msg_classes/message_base.py index 40ca0fa7..2677c73f 100644 --- a/extract_msg/msg_classes/message_base.py +++ b/extract_msg/msg_classes/message_base.py @@ -1200,8 +1200,9 @@ def htmlBodyPrepared(self) -> Optional[bytes]: cid = tag['src'][4:] data = next((attachment.data for attachment in self.attachments if attachment.cid == cid), None) # If we found anything, inject it. + if '.png' in cid: extention = b'/png' if data: - tag['src'] = (b'data:image;base64,' + base64.b64encode(data)).decode('utf-8') + tag['src'] = (b'data:image' + extention + b';base64,' + base64.b64encode(data)).decode('utf-8') return soup.prettify('utf-8')