Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions pymisp/tools/emailobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,10 @@ def _build_eml(self, message: EmailMessage, body: dict[str, Any], attachments: l
body.get('html'),
body.get('rtf')] if i is not None]
# If this a non-multipart email then we only need to attach the payload
if message.get_content_maintype() != 'multipart':
if (
message.get_content_maintype() != "multipart" and
"application/ms-tnef" not in message.get("content-type", message.get_content_maintype())
):
for _body in body_objects:
if "text/{}".format(_body['subtype']) == message.get_content_type():
message.set_content(**_body)
Expand Down Expand Up @@ -219,12 +222,13 @@ def _build_eml(self, message: EmailMessage, body: dict[str, Any], attachments: l
for attch in attachments: # Add attachments at the end.
if attch.cid not in related_content.keys():
_content_type = attch.getStringStream('__substg1.0_370E')
maintype, subtype = _content_type.split("/", 1)
message.add_attachment(attch.data,
maintype=maintype,
subtype=subtype,
cid=attch.cid,
filename=attch.longFilename)
if _content_type is not None:
maintype, subtype = _content_type.split("/", 1)
message.add_attachment(attch.data,
maintype=maintype,
subtype=subtype,
cid=attch.cid,
filename=attch.longFilename)
if p := message.get_payload():
if isinstance(p, list):
cur_attach = p[-1]
Expand Down