Loading django/utils/log.py +2 −5 Original line number Diff line number Diff line Loading @@ -128,12 +128,9 @@ class AdminEmailHandler(logging.Handler): def format_subject(self, subject): """ Escape CR and LF characters, and limit length. RFC 2822's hard limit is 998 characters per line. So, minus "Subject: " the actual subject must be no longer than 989 characters. Escape CR and LF characters. """ formatted_subject = subject.replace('\n', '\\n').replace('\r', '\\r') return formatted_subject[:989] return subject.replace('\n', '\\n').replace('\r', '\\r') class CallbackFilter(logging.Filter): Loading docs/releases/1.10.txt +4 −0 Original line number Diff line number Diff line Loading @@ -836,6 +836,10 @@ Miscellaneous <django.core.files.storage.Storage.generate_filename>` instead. It might be possible to use :attr:`~django.db.models.FileField.upload_to` also. * The subject of mail sent by ``AdminEmailHandler`` is no longer truncated at 989 characters. If you were counting on a limited length, truncate the subject yourself. .. _deprecated-features-1.10: Features deprecated in 1.10 Loading tests/logging_tests/tests.py +0 −22 Original line number Diff line number Diff line Loading @@ -299,28 +299,6 @@ class AdminEmailHandlerTest(SimpleTestCase): self.assertNotIn('\r', mail.outbox[0].subject) self.assertEqual(mail.outbox[0].subject, expected_subject) @override_settings( ADMINS=(('admin', 'admin@example.com'),), EMAIL_SUBJECT_PREFIX='', DEBUG=False, ) def test_truncate_subject(self): """ RFC 2822's hard limit is 998 characters per line. So, minus "Subject: ", the actual subject must be no longer than 989 characters. Refs #17281. """ message = 'a' * 1000 expected_subject = 'ERROR: aa' + 'a' * 980 self.assertEqual(len(mail.outbox), 0) self.logger.error(message) self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, expected_subject) @override_settings( ADMINS=[('admin', 'admin@example.com')], DEBUG=False, Loading Loading
django/utils/log.py +2 −5 Original line number Diff line number Diff line Loading @@ -128,12 +128,9 @@ class AdminEmailHandler(logging.Handler): def format_subject(self, subject): """ Escape CR and LF characters, and limit length. RFC 2822's hard limit is 998 characters per line. So, minus "Subject: " the actual subject must be no longer than 989 characters. Escape CR and LF characters. """ formatted_subject = subject.replace('\n', '\\n').replace('\r', '\\r') return formatted_subject[:989] return subject.replace('\n', '\\n').replace('\r', '\\r') class CallbackFilter(logging.Filter): Loading
docs/releases/1.10.txt +4 −0 Original line number Diff line number Diff line Loading @@ -836,6 +836,10 @@ Miscellaneous <django.core.files.storage.Storage.generate_filename>` instead. It might be possible to use :attr:`~django.db.models.FileField.upload_to` also. * The subject of mail sent by ``AdminEmailHandler`` is no longer truncated at 989 characters. If you were counting on a limited length, truncate the subject yourself. .. _deprecated-features-1.10: Features deprecated in 1.10 Loading
tests/logging_tests/tests.py +0 −22 Original line number Diff line number Diff line Loading @@ -299,28 +299,6 @@ class AdminEmailHandlerTest(SimpleTestCase): self.assertNotIn('\r', mail.outbox[0].subject) self.assertEqual(mail.outbox[0].subject, expected_subject) @override_settings( ADMINS=(('admin', 'admin@example.com'),), EMAIL_SUBJECT_PREFIX='', DEBUG=False, ) def test_truncate_subject(self): """ RFC 2822's hard limit is 998 characters per line. So, minus "Subject: ", the actual subject must be no longer than 989 characters. Refs #17281. """ message = 'a' * 1000 expected_subject = 'ERROR: aa' + 'a' * 980 self.assertEqual(len(mail.outbox), 0) self.logger.error(message) self.assertEqual(len(mail.outbox), 1) self.assertEqual(mail.outbox[0].subject, expected_subject) @override_settings( ADMINS=[('admin', 'admin@example.com')], DEBUG=False, Loading