@@ -3082,13 +3082,40 @@ def test_address_list_with_list_separator_after_fold(self):
30823082 self ._test (parser .get_address_list (to )[0 ],
30833083 f'{ a } ,\n =?utf-8?q?H=C3=BCbsch?= Kaktus <[email protected] >\n ' )
30843084
3085- a = '.' * 79
3085+ a = '.' * 79 # ('.' is a special, so must be in quoted-string.)
30863086 to = f'"{ a } " <[email protected] >, "Hübsch Kaktus" <[email protected] >' 30873087 self ._test (parser .get_address_list (to )[0 ],
3088- f'{ a } \n '
3088+ f'" { a } " \n '
30893089 ' <[email protected] >, =?utf-8?q?H=C3=BCbsch?= Kaktus ' 3090309030913091
3092+ def test_address_list_with_specials_in_long_quoted_string (self ):
3093+ # Regression for gh-80222.
3094+ policy = self .policy .clone (max_line_length = 40 )
3095+ cases = [
3096+ # (to, folded)
3097+ (
'"Exfiltrator <[email protected] > (unclosed comment?" <[email protected] >' ,
3098+ '"Exfiltrator <[email protected] > (unclosed\n ' 3099+ ' comment?" <[email protected] >\n ' ),
3100+ (
'"Escaped \\ " chars \\ \\ in quoted-string stay escaped" <[email protected] >' ,
3101+ '"Escaped \\ " chars \\ \\ in quoted-string\n '
3102+ ' stay escaped" <[email protected] >\n ' ),
3103+ (
'This long display name does not need quotes <[email protected] >' ,
3104+ 'This long display name does not need\n '
3105+ 3106+ (
'"Quotes are not required but are retained here" <[email protected] >' ,
3107+ '"Quotes are not required but are\n '
3108+ ' retained here" <[email protected] >\n ' ),
3109+ ('"A quoted-string, it can be a valid local-part"@example.com' ,
3110+ '"A quoted-string, it can be a valid\n '
3111+ ' local-part"@example.com\n ' ),
3112+ (
'"[email protected] "@example.com' ,
3113+ '"[email protected] "@example.com\n ' ),
3114+ ]
3115+ for (to , folded ) in cases :
3116+ with self .subTest (to = to ):
3117+ self ._test (parser .get_address_list (to )[0 ], folded , policy = policy )
3118+
30923119 # XXX Need tests with comments on various sides of a unicode token,
30933120 # and with unicode tokens in the comments. Spaces inside the quotes
30943121 # currently don't do the right thing.
0 commit comments