mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-24 19:41:36 +02:00
Use BeautifulSoup to get text out of HTML-only emails, to address issue in #565
This commit is contained in:
parent
8f375e1379
commit
65c1d05eef
@ -25,6 +25,8 @@ import base64
|
|||||||
import binascii
|
import binascii
|
||||||
from time import ctime
|
from time import ctime
|
||||||
|
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
from email_reply_parser import EmailReplyParser
|
from email_reply_parser import EmailReplyParser
|
||||||
|
|
||||||
from django.core.files.base import ContentFile
|
from django.core.files.base import ContentFile
|
||||||
@ -366,7 +368,12 @@ def ticket_from_message(message, queue, logger):
|
|||||||
counter += 1
|
counter += 1
|
||||||
|
|
||||||
if not body:
|
if not body:
|
||||||
body = _('No plain-text email body available. Please see attachment "email_html_body.html".')
|
mail = BeautifulSoup(part.get_payload(), "lxml")
|
||||||
|
if ">" in mail.text:
|
||||||
|
message_body = mail.text.split(">")[1]
|
||||||
|
body = message_body.encode('ascii', errors='ignore')
|
||||||
|
else:
|
||||||
|
body = mail.text
|
||||||
|
|
||||||
if ticket:
|
if ticket:
|
||||||
try:
|
try:
|
||||||
|
@ -2,6 +2,8 @@ Django>=1.11,<2
|
|||||||
django-bootstrap-form>=3.3,<4
|
django-bootstrap-form>=3.3,<4
|
||||||
email-reply-parser
|
email-reply-parser
|
||||||
django-markdown-deux
|
django-markdown-deux
|
||||||
|
beautifulsoup4
|
||||||
|
lxml
|
||||||
simplejson
|
simplejson
|
||||||
pytz
|
pytz
|
||||||
six
|
six
|
||||||
|
Loading…
x
Reference in New Issue
Block a user