Skip to content

Commit

Permalink
The assembly of the message was not correctly completed in specific J…
Browse files Browse the repository at this point in the history
…apanese.
  • Loading branch information
TAKAHASHI Kunihiko committed May 17, 2013
1 parent de7535d commit a562d9c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -1253,7 +1253,7 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
$formatted[] = '';
continue;
}
if (!preg_match('/\<[a-z]/i', $line)) {
if (!preg_match('/<[a-z]+.+>/i', $line)) {
$formatted = array_merge(
$formatted,
explode("\n", wordwrap($line, $wrapLength, "\n"))
Expand Down
32 changes: 32 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -1622,6 +1622,38 @@ public function testHeaderEncoding() {
$this->assertContains('ってテーブルを作ってやってたらう', $result['message']);
}

public function testWrapLongLine() {
$message = '<a href="http://cakephp.org">' . str_repeat('1234567890', 100) . "</a>";

$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('cake@cakephp.org');
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->config(array('empty'));
$result = $this->CakeEmail->send($message);
$expected = "<a\r\n" . 'href="http://cakephp.org">' . str_repeat('1234567890', 100) . "\r\n</a>\r\n\r\n";
$this->assertEquals($expected, $result['message']);
}

public function testWrapForJapaneseEncoding() {
$this->skipIf(!function_exists('mb_convert_encoding'));

$message = mb_convert_encoding('受け付けました', 'iso-2022-jp', 'UTF-8');

$this->CakeEmail->reset();
$this->CakeEmail->transport('Debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('cake@cakephp.org');
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->config(array('empty'));
$this->CakeEmail->charset('iso-2022-jp');
$this->CakeEmail->headerCharset('iso-2022-jp');
$result = $this->CakeEmail->send($message);
$expected = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
}

/**
* Tests that the body is encoded using the configured charset
*
Expand Down

0 comments on commit a562d9c

Please sign in to comment.