mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
#18431: Decode encoded words in atoms in new email parser.
There is more to be done here in terms of accepting RFC invalid input that some mailers accept, but this covers the valid RFC places where encoded words can occur in structured headers.
This commit is contained in:
parent
65171b28e7
commit
923512f327
4 changed files with 73 additions and 3 deletions
|
@ -808,9 +808,13 @@ class TestParser(TestParserMixin, TestEmailBase):
|
|||
self.assertEqual(atom[2].comments, ['bar'])
|
||||
|
||||
def test_get_atom_atom_ends_at_noncfws(self):
|
||||
atom = self._test_get_x(parser.get_atom,
|
||||
self._test_get_x(parser.get_atom,
|
||||
'bob fred', 'bob ', 'bob ', [], 'fred')
|
||||
|
||||
def test_get_atom_rfc2047_atom(self):
|
||||
self._test_get_x(parser.get_atom,
|
||||
'=?utf-8?q?=20bob?=', ' bob', ' bob', [], '')
|
||||
|
||||
# get_dot_atom_text
|
||||
|
||||
def test_get_dot_atom_text(self):
|
||||
|
@ -885,6 +889,10 @@ class TestParser(TestParserMixin, TestEmailBase):
|
|||
with self.assertRaises(errors.HeaderParseError):
|
||||
parser.get_dot_atom(' (foo) bar.bang. foo')
|
||||
|
||||
def test_get_dot_atom_rfc2047_atom(self):
|
||||
self._test_get_x(parser.get_dot_atom,
|
||||
'=?utf-8?q?=20bob?=', ' bob', ' bob', [], '')
|
||||
|
||||
# get_word (if this were black box we'd repeat all the qs/atom tests)
|
||||
|
||||
def test_get_word_atom_yields_atom(self):
|
||||
|
@ -2156,6 +2164,22 @@ class TestParser(TestParserMixin, TestEmailBase):
|
|||
self.assertEqual(address[0].token_type,
|
||||
'mailbox')
|
||||
|
||||
def test_get_address_rfc2047_display_name(self):
|
||||
address = self._test_get_x(parser.get_address,
|
||||
'=?utf-8?q?=C3=89ric?= <foo@example.com>',
|
||||
'Éric <foo@example.com>',
|
||||
'Éric <foo@example.com>',
|
||||
[],
|
||||
'')
|
||||
self.assertEqual(address.token_type, 'address')
|
||||
self.assertEqual(len(address.mailboxes), 1)
|
||||
self.assertEqual(address.mailboxes,
|
||||
address.all_mailboxes)
|
||||
self.assertEqual(address.mailboxes[0].display_name,
|
||||
'Éric')
|
||||
self.assertEqual(address[0].token_type,
|
||||
'mailbox')
|
||||
|
||||
def test_get_address_empty_group(self):
|
||||
address = self._test_get_x(parser.get_address,
|
||||
'Monty Python:;',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue