Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fa18010

Browse filesBrowse files
committed
bug #58593 [Mime] fix encoding issue with UTF-8 addresses containing doubles spaces (0xb4lint)
This PR was submitted for the 7.2 branch but it was squashed and merged into the 5.4 branch instead. Discussion ---------- [Mime] fix encoding issue with UTF-8 addresses containing doubles spaces | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #58592, Fix #50345 | License | MIT Commits ------- c6ed3c8 [Mime] fix encoding issue with UTF-8 addresses containing doubles spaces
2 parents f42d2ce + c6ed3c8 commit fa18010
Copy full SHA for fa18010

File tree

Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+22
-0
lines changed

‎src/Symfony/Component/Mime/Header/AbstractHeader.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Header/AbstractHeader.php
+14Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,20 @@ protected function getEncodableWordTokens(string $string): array
180180
$tokens[] = $encodedToken;
181181
}
182182

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+
183197
return $tokens;
184198
}
185199

‎src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Mime/Tests/Header/MailboxHeaderTest.php
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ public function testUtf8CharsInLocalPart()
6262
{
6363
$header = new MailboxHeader('Sender', new Address('fabïen@symfony.com'));
6464
$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());
6573
}
6674

6775
public function testToString()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.