Skip to content

Commit

Permalink
extract.extractors.msg:msg_attachment - if bytes data is shorter than…
Browse files Browse the repository at this point in the history
… minimal file size, assume it is not an MSG

Fix #748
  • Loading branch information
MatteoCampinoti94 committed Jan 23, 2025
1 parent 6203390 commit e82ef73
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions digiarch/commands/extract/extractors/extractor_msg.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from extract_msg.exceptions import ExMsgBaseException
from extract_msg.msg_classes import MeetingRelated
from extract_msg.msg_classes import MessageSigned
from olefile import MINIMAL_OLEFILE_SIZE

from digiarch.common import sanitize_filename
from digiarch.common import TempDir
Expand Down Expand Up @@ -76,6 +77,9 @@ def msg_attachment(attachment: AttachmentBase) -> Message | bool | None:
elif isinstance(attachment.data, (Message, MessageSigned, MeetingRelated)):
attachment_msg = attachment.data
elif isinstance(attachment.data, bytes):
# noinspection PyTypeChecker
if len(attachment.data) < MINIMAL_OLEFILE_SIZE:
return None
attachment_msg = openMsg(attachment.data, delayAttachments=True)
else:
raise TypeError(f"Unsupported attachment data type {type(attachment.data)}")
Expand Down

0 comments on commit e82ef73

Please sign in to comment.