Skip to content

Commit

Permalink
GH-100884: email/_header_value_parser: don't encode list separators
Browse files Browse the repository at this point in the history
ListSeparator should not be encoded. This could happen when a long line
pushes its separator to the next line, which would have been encoded.

Fixes #100884
  • Loading branch information
t-8ch committed Jan 9, 2023
1 parent b1f41b8 commit 75a89ca
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Lib/email/_header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,7 @@ class _InvalidEwError(errors.HeaderParseError):
# up other parse trees. Maybe should have tests for that, too.
DOT = ValueTerminal('.', 'dot')
ListSeparator = ValueTerminal(',', 'list-separator')
ListSeparator.as_ew_allowed = False
RouteComponentMarker = ValueTerminal('@', 'route-component-marker')

#
Expand Down
5 changes: 5 additions & 0 deletions Lib/test/test_email/test__header_value_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -2946,6 +2946,11 @@ def test_address_list_with_unicode_names_in_quotes(self):
'=?utf-8?q?H=C3=BCbsch?= Kaktus <beautiful@example.com>,\n'
' =?utf-8?q?bei=C3=9Ft_bei=C3=9Ft?= <biter@example.com>\n')

def test_address_list_with_list_separator_after_fold(self):
to = '0123456789' * 8 + '@foo, ä <foo@bar>'
self._test(parser.get_address_list(to)[0],
'0123456789' * 8 + '@foo,\n =?utf-8?q?=C3=A4?= <foo@bar>\n')

# XXX Need tests with comments on various sides of a unicode token,
# and with unicode tokens in the comments. Spaces inside the quotes
# currently don't do the right thing.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
email: fix misfolding of comma in address-lists over multiple lines in
combination with unicode encoding.

0 comments on commit 75a89ca

Please sign in to comment.