File tree 2 files changed +22
-0
lines changed
src/Symfony/Component/Mime 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -180,6 +180,20 @@ protected function getEncodableWordTokens(string $string): array
180
180
$ tokens [] = $ encodedToken ;
181
181
}
182
182
183
+ foreach ($ tokens as $ i => $ token ) {
184
+ // whitespace(s) between 2 encoded tokens
185
+ if (
186
+ 0 < $ i
187
+ && isset ($ tokens [$ i + 1 ])
188
+ && preg_match ('~^[\t ]+$~ ' , $ token )
189
+ && $ this ->tokenNeedsEncoding ($ tokens [$ i - 1 ])
190
+ && $ this ->tokenNeedsEncoding ($ tokens [$ i + 1 ])
191
+ ) {
192
+ $ tokens [$ i - 1 ] .= $ token .$ tokens [$ i + 1 ];
193
+ array_splice ($ tokens , $ i , 2 );
194
+ }
195
+ }
196
+
183
197
return $ tokens ;
184
198
}
185
199
Original file line number Diff line number Diff line change @@ -62,6 +62,14 @@ public function testUtf8CharsInLocalPart()
62
62
{
63
63
$ header = new MailboxHeader ('Sender ' , new Address ('fabïen@symfony.com ' ));
64
64
$ this ->assertSame ('fabïen@symfony.com ' , $ header ->getBodyAsString ());
65
+
66
+ // name with single space
67
+ $ header = new MailboxHeader ('Sender ' , new Address ('fabïen@symfony.com ' , 'Fabïen Pötencier ' ));
68
+ $ this ->assertSame ('=?utf-8?Q?Fab=C3=AFen_P=C3=B6tencier?= <fabïen@symfony.com> ' , $ header ->getBodyAsString ());
69
+
70
+ // name with double spaces
71
+ $ header = new MailboxHeader ('Sender ' , new Address ('fabïen@symfony.com ' , 'Fabïen Pötencier ' ));
72
+ $ this ->assertSame ('=?utf-8?Q?Fab=C3=AFen__P=C3=B6tencier?= <fabïen@symfony.com> ' , $ header ->getBodyAsString ());
65
73
}
66
74
67
75
public function testToString ()
You can’t perform that action at this time.
0 commit comments