From 55b55edb90a21aa127fcb3071fe6ec81f809dff8 Mon Sep 17 00:00:00 2001 From: Garret Wassermann Date: Tue, 13 Feb 2018 22:25:50 -0500 Subject: [PATCH] Fix bug in get_email where HTML tags sometimes included in text, reported in #565 --- helpdesk/management/commands/get_email.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/helpdesk/management/commands/get_email.py b/helpdesk/management/commands/get_email.py index 94ad204c..f7d00724 100755 --- a/helpdesk/management/commands/get_email.py +++ b/helpdesk/management/commands/get_email.py @@ -395,8 +395,9 @@ def ticket_from_message(message, queue, logger): if not body: mail = BeautifulSoup(part.get_payload(), "lxml") if ">" in mail.text: - message_body = mail.text.split(">")[1] - body = message_body.encode('ascii', errors='ignore') + body = mail.find('body') + body = body.text + body = body.encode('ascii', errors='ignore') else: body = mail.text