fix: Mail body can be empty...

tests
Raphaël Vinot 2018-05-07 18:22:14 +02:00
parent d9de8f7344
commit dd0d127f8c
1 changed files with 14 additions and 12 deletions

View File

@ -123,7 +123,9 @@ class Mail2MISP():
return email_object
def process_email_body(self):
self.clean_email_body = html.unescape(self.original_mail.get_body().get_payload(decode=True).decode())
mail_as_bytes = self.original_mail.get_body().get_payload(decode=True)
if mail_as_bytes:
self.clean_email_body = html.unescape(mail_as_bytes.decode())
# Check if there are config lines in the body & convert them to a python dictionary:
# <config.body_config_prefix>:<key>:<value> => {<key>: <value>}
self.config_from_email_body = {k: v for k, v in re.findall(f'{config.body_config_prefix}:(.*):(.*)', self.clean_email_body)}