From 0207a61e9ba357219740cdf716a75f17419572bf Mon Sep 17 00:00:00 2001 From: mark_story Date: Sat, 11 Feb 2012 10:15:53 -0500 Subject: [PATCH] Move alias wrapping into _formatAddress() Fixes #2502 --- lib/Cake/Network/Email/CakeEmail.php | 6 +++--- lib/Cake/Test/Case/Network/Email/CakeEmailTest.php | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index 69c3982c2..c9aaf72ce 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -686,6 +686,9 @@ class CakeEmail { if ($email === $alias) { $return[] = $email; } else { + if (strpos($alias, ',') !== false) { + $alias = '"' . $alias . '"'; + } $return[] = sprintf('%s <%s>', $this->_encode($alias), $email); } } @@ -1109,9 +1112,6 @@ 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); diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index a962bab1c..3c8c0d0fb 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -395,6 +395,8 @@ class CakeEmailTest extends CakeTestCase { $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');