Skip to content

Commit

Permalink
Move alias wrapping into _formatAddress()
Browse files Browse the repository at this point in the history
Fixes #2502
  • Loading branch information
markstory committed Feb 11, 2012
1 parent e1dba67 commit 0207a61
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -686,6 +686,9 @@ protected function _formatAddress($address) {
if ($email === $alias) {
$return[] = $email;
} else {
if (strpos($alias, ',') !== false) {
$alias = '"' . $alias . '"';
}
$return[] = sprintf('%s <%s>', $this->_encode($alias), $email);
}
}
Expand Down Expand Up @@ -1109,9 +1112,6 @@ 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
2 changes: 2 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -395,6 +395,8 @@ public function testSubject() {
$this->CakeEmail->subject('You have a new message.');
$this->assertSame($this->CakeEmail->subject(), 'You have a new message.');

$this->CakeEmail->subject('You have a new message, I think.');
$this->assertSame($this->CakeEmail->subject(), 'You have a new message, I think.');
$this->CakeEmail->subject(1);
$this->assertSame($this->CakeEmail->subject(), '1');

Expand Down

0 comments on commit 0207a61

Please sign in to comment.