8000 GH-100884: email/_header_value_parser: don't encode list separators · python/cpython@75a89ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 75a89ca

Browse files
committed
GH-100884: email/_header_value_parser: don't encode list separators
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
1 parent b1f41b8 commit 75a89ca

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

Lib/email/_header_value_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ class _InvalidEwError(errors.HeaderParseError):
949949
# up other parse trees. Maybe should have tests for that, too.
950950
DOT = ValueTerminal('.', 'dot')
951951
ListSeparator = ValueTerminal(',', 'list-separator')
952+
ListSeparator.as_ew_allowed = False
952953
RouteComponentMarker = ValueTerminal('@', 'route-component-marker')
953954

954955
#

Lib/test/test_email/test__header_value_parser.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2946,6 +2946,11 @@ def test_address_list_with_unicode_names_in_quotes(self):
29462946
'=?utf-8?q?H=C3=BCbsch?= Kaktus <beautiful@example.com>,\n'
29472947
' =?utf-8?q?bei=C3=9Ft_bei=C3=9Ft?= <biter@example.com>\n')
29482948

2949+
def test_address_list_with_list_separator_after_fold(self):
2950+
to = '0123456789' * 8 + '@foo, ä <foo@bar>'
2951+
self._test(parser.get_address_list(to)[0],
2952+
'0123456789' * 8 + '@foo,\n =?utf-8?q?=C3=A4?= <foo@bar>\n')
2953+
29492954
# XXX Need tests with comments on various sides of a unicode token,
29502955
# and with unicode tokens in the comments. Spaces inside the quotes
29512956
# currently don't do the right thing.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
email: fix misfolding of comma in address-lists over multiple lines in
2+
combination with unicode encoding.

0 commit comments

Comments
 (0)
0