#27051: Exception when using a single space character as e-mail subject
-----------------------------+---------------------------------
     Reporter:  MoritzS      |      Owner:  nobody
         Type:  Bug          |     Status:  new
    Component:  Core (Mail)  |    Version:  master
     Severity:  Normal       |   Keywords:  mail subject header
 Triage Stage:  Unreviewed   |  Has patch:  0
Easy pickings:  0            |      UI/UX:  0
-----------------------------+---------------------------------
 Steps to reproduce:


 {{{
 Python 3.5.2 (default, Jun 28 2016, 08:46:01)
 [GCC 6.1.1 20160602] on linux
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import django.conf
 >>> django.conf.settings.configure()
 >>> from django.core import mail
 >>> mail.EmailMessage(subject=' ',
 from_email='[email protected]').message()
 Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "/home/user/django/django/core/mail/message.py", line 311, in
 message
     msg['Subject'] = self.subject
   File "/home/user/django/django/core/mail/message.py", line 236, in
 __setitem__
     name, val = forbid_multi_line_headers(name, val, self.encoding)
   File "/home/user/django/django/core/mail/message.py", line 102, in
 forbid_multi_line_headers
     val = Header(val).encode()
   File "/usr/lib/python3.5/email/header.py", line 387, in encode
     value = formatter._str(linesep)
   File "/usr/lib/python3.5/email/header.py", line 423, in _str
     self.newline()
   File "/usr/lib/python3.5/email/header.py", line 435, in newline
     self._lines[-1] += str(self._current_line)
 IndexError: list index out of range
 }}}

 This error doesn't occur when directly setting `msg['Subject'] = ' '` on a
 plain `email.message.Message`. Using subjects like `' foo'` or `'foo '`
 also works.

 It might still be a bug in Python, though, as the Exception isn't raised
 in Django's code but in the `email` module while trying to encode the
 Subject header.

--
Ticket URL: <https://code.djangoproject.com/ticket/27051>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.9e19c98c8a50e2e6dd8f84f3ecb9d056%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to