Merge branch 'master' into 2.5

This commit is contained in:
mark_story 2013-11-07 23:01:25 -05:00
commit 2e7d687b98
3 changed files with 18 additions and 7 deletions

View file

@ -767,7 +767,7 @@ class CakeRequest implements ArrayAccess {
* {{{ CakeRequest::acceptLanguage('es-es'); }}}
*
* @param string $language The language to test.
* @return If a $language is provided, a boolean. Otherwise the array of accepted languages.
* @return mixed If a $language is provided, a boolean. Otherwise the array of accepted languages.
*/
public static function acceptLanguage($language = null) {
$raw = self::_parseAcceptWithQualifier(self::header('Accept-Language'));

View file

@ -40,6 +40,9 @@ class MailTransport extends AbstractTransport {
$headers = $email->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc'));
$to = $headers['To'];
unset($headers['To']);
foreach ($headers as $key => $header) {
$headers[$key] = str_replace(array("\r", "\n"), '', $header);
}
$headers = $this->_headersToString($headers, $eol);
$message = implode($eol, $email->message());
$subject = str_replace(array("\r", "\n"), '', $email->subject());

View file

@ -52,10 +52,19 @@ class MailTransportTest extends CakeTestCase {
$email->cc(array('mark@cakephp.org' => 'Mark Story', 'juan@cakephp.org' => 'Juan Basso'));
$email->bcc('phpnut@cakephp.org');
$email->messageID('<4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>');
$email->subject('Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz');
$longNonAscii = 'Foø Bår Béz Foø Bår Béz Foø Bår Béz Foø Bår Béz';
$email->subject($longNonAscii);
$date = date(DATE_RFC2822);
$email->setHeaders(array('X-Mailer' => 'CakePHP Email', 'Date' => $date));
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
$email->setHeaders(array(
'X-Mailer' => 'CakePHP Email',
'Date' => $date,
'X-add' => mb_encode_mimeheader($longNonAscii, 'utf8', 'B'),
));
$email->expects($this->any())->method('message')
->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
$encoded = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
$encoded .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
$data = "From: CakePHP Test <noreply@cakephp.org>" . PHP_EOL;
$data .= "Return-Path: CakePHP Return <pleasereply@cakephp.org>" . PHP_EOL;
@ -63,17 +72,16 @@ class MailTransportTest extends CakeTestCase {
$data .= "Bcc: phpnut@cakephp.org" . PHP_EOL;
$data .= "X-Mailer: CakePHP Email" . PHP_EOL;
$data .= "Date: " . $date . PHP_EOL;
$data .= "X-add: " . $encoded . PHP_EOL;
$data .= "Message-ID: <4d9946cf-0a44-4907-88fe-1d0ccbdd56cb@localhost>" . PHP_EOL;
$data .= "MIME-Version: 1.0" . PHP_EOL;
$data .= "Content-Type: text/plain; charset=UTF-8" . PHP_EOL;
$data .= "Content-Transfer-Encoding: 8bit";
$subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
$subject .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
$this->MailTransport->expects($this->once())->method('_mail')
->with(
'CakePHP <cake@cakephp.org>',
$subject,
$encoded,
implode(PHP_EOL, array('First Line', 'Second Line', '.Third Line', '')),
$data,
'-f'