#27007: Handle non-UTF-8 bytes objects for text/* attachments
-------------------------------------+-------------------------------------
     Reporter:  Michael Schwarz      |                    Owner:  nobody
         Type:                       |                   Status:  closed
  Cleanup/optimization               |
    Component:  Core (Mail)          |                  Version:  dev
     Severity:  Normal               |               Resolution:  fixed
     Keywords:                       |             Triage Stage:  Ready for
                                     |  checkin
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Comment (by Sarah Boyce <42296566+sarahboyce@…>):

 In [changeset:"23529b662793cdf4725d5f8ff58f0df94b343365" 23529b66]:
 {{{#!CommitTicketReference repository=""
 revision="23529b662793cdf4725d5f8ff58f0df94b343365"
 Fixed #36478 -- Fixed inconsistent mail attachment handling.

 Fixed an inconsistency between EmailMessage.attach() and .attachments
 when attaching bytes content with a text/* mimetype. The attach()
 function decodes UTF-8 bytes if possible and otherwise changes the
 mimetype to application/octet-stream to preserve the content's unknown
 encoding (refs #27007). Providing equivalent content directly in
 EmailMessage.attachments did not apply the same logic, leading
 to an "AttributeError: 'bytes' object has no attribute 'encode'"
 in SafeMIMEText.set_payload().

 Updated EmailMessage._create_mime_attachment() to match attach()'s
 handling for text/* mimetypes with bytes content. Updated test cases
 to accurately cover behavior on both paths.
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/27007#comment:10>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/django-updates/01070197ab03d8bd-5aae4fad-c9fc-46ae-880f-48d9fe73f0ec-000000%40eu-central-1.amazonses.com.

Reply via email to