diff --git a/.travis.yml b/.travis.yml index 049b1a3..13ede5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ addons: apt: packages: - libfuzzy-dev + - libemail-outlook-message-perl python: - "3.6" diff --git a/pymisp/tools/emailobject.py b/pymisp/tools/emailobject.py index 303c26e..1e4aa41 100644 --- a/pymisp/tools/emailobject.py +++ b/pymisp/tools/emailobject.py @@ -87,7 +87,6 @@ class EMailObject(AbstractMISPObjectGenerator): logger.debug("EmailObject was passed a non-ASCII encoded binary blob.") try: if bytes[:3] == b'\xef\xbb\xbf': # utf-8-sig byte-order mark (BOM) - # Set Pseudofile to correctly encoded email in case it is used at some later point. bytes = bytes.decode("utf_8_sig").encode("ASCII") message = email.message_from_bytes(bytes, policy=policy.default) # type: ignore return message diff --git a/tests/email_testfiles/mail_1.msg b/tests/email_testfiles/mail_1.msg new file mode 100644 index 0000000..f3af692 Binary files /dev/null and b/tests/email_testfiles/mail_1.msg differ diff --git a/tests/test_emailobject.py b/tests/test_emailobject.py index 02ffa46..74111ce 100644 --- a/tests/test_emailobject.py +++ b/tests/test_emailobject.py @@ -22,5 +22,16 @@ class TestEmailObject(unittest.TestCase): self.assertIsInstance(file_name, str) self.assertIsInstance(file_content, BytesIO) - def _get_values(self, obj: EMailObject, relation: str) -> List[str]: + def test_mail_1_msg(self): + email_object = EMailObject(Path("tests/email_testfiles/mail_1.msg")) + self.assertEqual(self._get_values(email_object, "subject")[0], + "Newsletter Prüfung Personalwesen / Prüfung Eröffnungsbilanz") + + self.assertIsInstance(email_object.email, EmailMessage) + for file_name, file_content in email_object.attachments: + self.assertIsInstance(file_name, str) + self.assertIsInstance(file_content, BytesIO) + + @staticmethod + def _get_values(obj: EMailObject, relation: str) -> List[str]: return [attr.value for attr in obj.attributes if attr['object_relation'] == relation] \ No newline at end of file