Loading django/core/mail/message.py +6 −3 Original line number Diff line number Diff line Loading @@ -224,17 +224,20 @@ class EmailMessage(object): necessary encoding conversions. """ if to: assert not isinstance(to, six.string_types), '"to" argument must be a list or tuple' if isinstance(to, six.string_types): raise TypeError('"to" argument must be a list or tuple') self.to = list(to) else: self.to = [] if cc: assert not isinstance(cc, six.string_types), '"cc" argument must be a list or tuple' if isinstance(cc, six.string_types): raise TypeError('"cc" argument must be a list or tuple') self.cc = list(cc) else: self.cc = [] if bcc: assert not isinstance(bcc, six.string_types), '"bcc" argument must be a list or tuple' if isinstance(bcc, six.string_types): raise TypeError('"bcc" argument must be a list or tuple') self.bcc = list(bcc) else: self.bcc = [] Loading tests/mail/tests.py +8 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,14 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): self.assertEqual(message['Cc'], 'cc@example.com, cc.other@example.com') self.assertEqual(email.recipients(), ['to@example.com', 'other@example.com', 'cc@example.com', 'cc.other@example.com', 'bcc@example.com']) def test_recipients_as_string(self): with self.assertRaisesMessage(TypeError, '"to" argument must be a list or tuple'): EmailMessage(to='foo@example.com') with self.assertRaisesMessage(TypeError, '"cc" argument must be a list or tuple'): EmailMessage(cc='foo@example.com') with self.assertRaisesMessage(TypeError, '"bcc" argument must be a list or tuple'): EmailMessage(bcc='foo@example.com') def test_header_injection(self): email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com']) self.assertRaises(BadHeaderError, email.message) Loading Loading
django/core/mail/message.py +6 −3 Original line number Diff line number Diff line Loading @@ -224,17 +224,20 @@ class EmailMessage(object): necessary encoding conversions. """ if to: assert not isinstance(to, six.string_types), '"to" argument must be a list or tuple' if isinstance(to, six.string_types): raise TypeError('"to" argument must be a list or tuple') self.to = list(to) else: self.to = [] if cc: assert not isinstance(cc, six.string_types), '"cc" argument must be a list or tuple' if isinstance(cc, six.string_types): raise TypeError('"cc" argument must be a list or tuple') self.cc = list(cc) else: self.cc = [] if bcc: assert not isinstance(bcc, six.string_types), '"bcc" argument must be a list or tuple' if isinstance(bcc, six.string_types): raise TypeError('"bcc" argument must be a list or tuple') self.bcc = list(bcc) else: self.bcc = [] Loading
tests/mail/tests.py +8 −0 Original line number Diff line number Diff line Loading @@ -95,6 +95,14 @@ class MailTests(HeadersCheckMixin, SimpleTestCase): self.assertEqual(message['Cc'], 'cc@example.com, cc.other@example.com') self.assertEqual(email.recipients(), ['to@example.com', 'other@example.com', 'cc@example.com', 'cc.other@example.com', 'bcc@example.com']) def test_recipients_as_string(self): with self.assertRaisesMessage(TypeError, '"to" argument must be a list or tuple'): EmailMessage(to='foo@example.com') with self.assertRaisesMessage(TypeError, '"cc" argument must be a list or tuple'): EmailMessage(cc='foo@example.com') with self.assertRaisesMessage(TypeError, '"bcc" argument must be a list or tuple'): EmailMessage(bcc='foo@example.com') def test_header_injection(self): email = EmailMessage('Subject\nInjection Test', 'Content', 'from@example.com', ['to@example.com']) self.assertRaises(BadHeaderError, email.message) Loading