mirror of
https://github.com/django/django.git
synced 2025-08-04 02:48:35 +00:00
Fixed #27007 -- Handled non-UTF-8 bytes objects for text/* attachments.
The fallback logic which allows non-UTF-8 encoded files to be passed to attach_file() even when a `text/*` mime type has been specified is moved to attach(). Both functions now fall back to a content type of `application/octet-stream`. A side effect is that a file's content is decoded in memory instead of opening it in text mode and reading it into a string. Some mimetype-related logic in _create_attachment() has become obsolete as the code moved from attach_file() to attach() already handles this.
This commit is contained in:
parent
311a8e8d50
commit
72d541b61c
5 changed files with 72 additions and 28 deletions
|
@ -162,6 +162,10 @@ Email
|
|||
* Added the :setting:`EMAIL_USE_LOCALTIME` setting to allow sending SMTP date
|
||||
headers in the local time zone rather than in UTC.
|
||||
|
||||
* ``EmailMessage.attach()`` and ``attach_file()`` now fall back to MIME type
|
||||
``application/octet-stream`` when binary content that can't be decoded as
|
||||
UTF-8 is specified for a ``text/*`` attachment.
|
||||
|
||||
File Storage
|
||||
~~~~~~~~~~~~
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue