Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Wrap aliases containing , in ""

Fixes #2502
  • Loading branch information...
commit f02a3b05318ab1725a1b58ab2eea1677c4c2a7f6 1 parent 6d69ec3
@markstory markstory authored
View
3  lib/Cake/Network/Email/CakeEmail.php
@@ -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);
View
8 lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
@@ -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);
Please sign in to comment.
Something went wrong with that request. Please try again.