From e66c42890c5ef3db4f1683c404708b5486ee4e7d Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Wed, 19 Dec 2018 17:12:46 +0100 Subject: [PATCH] Don't crash when mail body is empty --- helpdesk/email.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/helpdesk/email.py b/helpdesk/email.py index 3a95d198..96f3ec13 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -362,11 +362,13 @@ def ticket_from_message(message, queue, logger): if not body: mail = BeautifulSoup(part.get_payload(), "lxml") - if ">" in mail.text: - body = mail.find('body') - body = body.text - body = body.encode('ascii', errors='ignore') - else: + beautiful_body = mail.find('body') + if beautiful_body: + try: + body = beautiful_body.text + except AttributeError: + pass + if not body: body = mail.text if ticket: