[Django] #26496: AdminEmailHandler can produce mails violating RFC2822

15 views
Skip to first unread message

Django

unread,
Apr 13, 2016, 4:44:52 AM4/13/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+-----------------
Reporter: nijel | Owner:
Type: Bug | Status: new
Component: Error reporting | Version: 1.9
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
---------------------------------+-----------------
The RFC2822 specifies maximal length of line in a message to 998
characters (see also https://code.djangoproject.com/ticket/22561). However
with AdminEmailHandler it's quite easy to reach it once settings contains
some more complex dictionary, which is always printed on single line.

The problematic template is TECHNICAL_500_TEXT_TEMPLATE in
django/views/debug.py:

https://github.com/django/django/blob/master/django/views/debug.py#L1121

Specially this code:

{{{
Using settings module {{ settings.SETTINGS_MODULE }}{% for k, v in
settings.items|dictsort:0 %}
{{ k }} = {{ v|stringformat:"r" }}{% endfor %}
}}}


I think best approach would be to use pformat for formatting those entries
same as is used for request parameters.

--
Ticket URL: <https://code.djangoproject.com/ticket/26496>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 13, 2016, 7:28:47 AM4/13/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+------------------------------------

Reporter: nijel | Owner:
Type: Bug | Status: new
Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:1>

Django

unread,
Apr 17, 2016, 3:29:14 PM4/17/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+------------------------------------

Reporter: nijel | Owner:
Type: Bug | Status: new
Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by claudep):

* easy: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:2>

Django

unread,
Apr 19, 2016, 2:16:20 AM4/19/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+------------------------------------
Reporter: nijel | Owner: filias
Type: Bug | Status: assigned

Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by filias):

* owner: => filias
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:3>

Django

unread,
Apr 29, 2016, 2:01:45 AM4/29/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+------------------------------------

Reporter: nijel | Owner:
Type: Bug | Status: new
Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by filias):

* owner: filias =>
* status: assigned => new


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:4>

Django

unread,
Apr 30, 2016, 12:44:37 PM4/30/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+---------------------------------------
Reporter: nijel | Owner: SachitNayak
Type: Bug | Status: assigned

Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+---------------------------------------
Changes (by SachitNayak):

* owner: => SachitNayak


* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:5>

Django

unread,
Jun 2, 2016, 1:05:48 PM6/2/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+------------------------------------

Reporter: nijel | Owner:
Type: Bug | Status: new
Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+------------------------------------
Changes (by carljm):

* owner: SachitNayak =>


* status: assigned => new


Comment:

Since there hasn't been progress in the 5 weeks since this ticket was
assigned, I'm de-assigning it to free it up for a PyCon sprinter.

--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:6>

Django

unread,
Jun 2, 2016, 1:13:21 PM6/2/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+-------------------------------------
Reporter: nijel | Owner: knightrix
Type: Bug | Status: assigned

Component: Error reporting | Version: 1.9
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+-------------------------------------
Changes (by knightrix):

* status: new => assigned

* owner: => knightrix


--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:7>

Django

unread,
Jun 3, 2016, 1:31:46 PM6/3/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+-------------------------------------
Reporter: nijel | Owner: knightrix
Type: Bug | Status: closed

Component: Error reporting | Version: 1.9
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+-------------------------------------
Changes (by knightrix):

* status: assigned => closed
* resolution: => fixed


Comment:

It looks like this is fixed by #22561. I modified the test like below and
it passed for the use case.
{{{#!python
def test_send_long_lines(self):
email = EmailMessage('Subject', "Commentçava},{'this': {'another':
{'more': 'nested'}, 'inner': 'myinner'}, 'that': 'hi'}" * 100,
'fr...@example.com', ['t...@example.com'])
email.send()
message = self.get_the_message()
message_content = message.get_payload()
has_long_lines = any(len(l) > 998 for l in
message_content.splitlines())
self.assertFalse(has_long_lines)

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:8>

Django

unread,
Jun 3, 2016, 2:21:22 PM6/3/16
to django-...@googlegroups.com
#26496: AdminEmailHandler can produce mails violating RFC2822
---------------------------------+-------------------------------------
Reporter: nijel | Owner: knightrix
Type: Bug | Status: closed
Component: Error reporting | Version: 1.9
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
---------------------------------+-------------------------------------

Comment (by timgraham):

More friendly formatting of dictionaries may still be useful if someone is
so inclined to reopen the ticket and make that change.

--
Ticket URL: <https://code.djangoproject.com/ticket/26496#comment:9>

Reply all
Reply to author
Forward
0 new messages