Skip to content

Commit

Permalink
Wrap aliases containing , in ""
Browse files Browse the repository at this point in the history
Fixes #2502
  • Loading branch information
markstory committed Jan 26, 2012
1 parent 6d69ec3 commit f02a3b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -1109,6 +1109,9 @@ protected function _encode($text) {
$restore = mb_internal_encoding();
mb_internal_encoding($this->_appCharset);
}
if (strpos($text, ',') !== false) {
$text = '"' . $text . '"';
}
$return = mb_encode_mimeheader($text, $this->headerCharset, 'B');
if ($internalEncoding) {
mb_internal_encoding($restore);
Expand Down
8 changes: 8 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -277,6 +277,14 @@ public function testFormatAddress() {
$expected = array('CakePHP <cake@cakephp.org>', 'Cake <php@cakephp.org>');
$this->assertSame($expected, $result);

$result = $this->CakeEmail->formatAddress(array('me@example.com' => 'Last, First'));
$expected = array('"Last, First" <me@example.com>');
$this->assertSame($expected, $result);

$result = $this->CakeEmail->formatAddress(array('me@example.com' => 'Last First'));
$expected = array('Last First <me@example.com>');
$this->assertSame($expected, $result);

$result = $this->CakeEmail->formatAddress(array('cake@cakephp.org' => 'ÄÖÜTest'));
$expected = array('=?UTF-8?B?w4TDlsOcVGVzdA==?= <cake@cakephp.org>');
$this->assertSame($expected, $result);
Expand Down

0 comments on commit f02a3b0

Please sign in to comment.