Skip to content

Commit

Permalink
Merge branch '5.4' into 6.4
Browse files Browse the repository at this point in the history
* 5.4:
  initialize RedisAdapter cursor to 0
  do not skip tests from data providers
  ensure compatibility with Twig 3.15
  [Mime] fix encoding issue with UTF-8 addresses containing doubles spaces
  fix translation file syntax
  [Validator] [Choice] Fix callback option if not array returned
  [DependencyInjection] Fix linting factories implemented via __callStatic
  [DependencyInjection] Fix replacing abstract arguments with bindings
  Minor fixes around parse_url() checks
  Ensure compatibility with mongodb v2
  Add missing translations for Turkish (tr)
  • Loading branch information
nicolas-grekas committed Oct 25, 2024
2 parents 108ffe3 + 8c1b9b3 commit 1de1cf1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Header/AbstractHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,20 @@ protected function getEncodableWordTokens(string $string): array
$tokens[] = $encodedToken;
}

foreach ($tokens as $i => $token) {
// whitespace(s) between 2 encoded tokens
if (
0 < $i
&& isset($tokens[$i + 1])
&& preg_match('~^[\t ]+$~', $token)
&& $this->tokenNeedsEncoding($tokens[$i - 1])
&& $this->tokenNeedsEncoding($tokens[$i + 1])
) {
$tokens[$i - 1] .= $token.$tokens[$i + 1];
array_splice($tokens, $i, 2);
}
}

return $tokens;
}

Expand Down
8 changes: 8 additions & 0 deletions Tests/Header/MailboxHeaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ public function testUtf8CharsInLocalPart()
{
$header = new MailboxHeader('Sender', new Address('fabï[email protected]'));
$this->assertSame('fabï[email protected]', $header->getBodyAsString());

// name with single space
$header = new MailboxHeader('Sender', new Address('fabï[email protected]', 'Fabïen Pötencier'));
$this->assertSame('=?utf-8?Q?Fab=C3=AFen_P=C3=B6tencier?= <fabï[email protected]>', $header->getBodyAsString());

// name with double spaces
$header = new MailboxHeader('Sender', new Address('fabï[email protected]', 'Fabïen Pötencier'));
$this->assertSame('=?utf-8?Q?Fab=C3=AFen__P=C3=B6tencier?= <fabï[email protected]>', $header->getBodyAsString());
}

public function testToString()
Expand Down

0 comments on commit 1de1cf1

Please sign in to comment.