Wrap aliases containing , in ""

Fixes #2502
This commit is contained in:
mark_story 2012-01-25 21:03:03 -05:00
parent 6d69ec3a78
commit f02a3b0531
2 changed files with 11 additions and 0 deletions

View file

@ -1109,6 +1109,9 @@ class CakeEmail {
$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);

View file

@ -277,6 +277,14 @@ class CakeEmailTest extends CakeTestCase {
$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);