mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #27848 -- Prevented crash when attaching a .eml file to a message
Thanks Sébastien Ramage for the report.
This commit is contained in:
parent
bde86ce9ae
commit
9a9e228321
@ -381,7 +381,7 @@ class EmailMessage:
|
||||
elif not isinstance(content, Message):
|
||||
# For compatibility with existing code, parse the message
|
||||
# into an email.Message object if it is not one already.
|
||||
content = message_from_string(content)
|
||||
content = message_from_string(force_text(content))
|
||||
|
||||
attachment = SafeMIMEMessage(content, subtype)
|
||||
else:
|
||||
|
44
tests/mail/attachments/file.eml
Normal file
44
tests/mail/attachments/file.eml
Normal file
@ -0,0 +1,44 @@
|
||||
MIME-Version: 1.0
|
||||
Received: by 10.220.191.194 with HTTP; Wed, 11 May 2011 12:27:12 -0700 (PDT)
|
||||
Date: Wed, 11 May 2011 13:27:12 -0600
|
||||
Delivered-To: jncjkq@gmail.com
|
||||
Message-ID: <BANLkTi=JCQO1h3ET-pT_PLEHejhSSYxTZw@mail.jncjkq.com>
|
||||
Subject: Test
|
||||
From: Bill Jncjkq <jncjkq@gmail.com>
|
||||
To: bookmarks@jncjkq.net
|
||||
Content-Type: multipart/mixed; boundary=bcaec54eecc63acce904a3050f79
|
||||
|
||||
--bcaec54eecc63acce904a3050f79
|
||||
Content-Type: multipart/alternative; boundary=bcaec54eecc63acce604a3050f77
|
||||
|
||||
--bcaec54eecc63acce604a3050f77
|
||||
Content-Type: text/plain; charset=ISO-8859-1
|
||||
|
||||
--
|
||||
Bill Jncjkq
|
||||
|
||||
--bcaec54eecc63acce604a3050f77
|
||||
Content-Type: text/html; charset=ISO-8859-1
|
||||
|
||||
<br clear="all">--<br>Bill Jncjkq<br>
|
||||
|
||||
--bcaec54eecc63acce604a3050f77--
|
||||
--bcaec54eecc63acce904a3050f79
|
||||
Content-Type: text/html; charset=US-ASCII; name="bookmarks-really-short.html"
|
||||
Content-Disposition: attachment; filename="bookmarks-really-short.html"
|
||||
Content-Transfer-Encoding: base64
|
||||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TestCase):
|
||||
('file_png', None),
|
||||
('file_txt.png', 'image/png'),
|
||||
('file_png.txt', 'text/plain'),
|
||||
('file.eml', 'message/rfc822'),
|
||||
)
|
||||
test_mimetypes = ['text/plain', 'image/png', None]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user