Skip to content

Commit

Permalink
Merge pull request #5202 from ndm2/email-zero-only-lines-fix
Browse files Browse the repository at this point in the history
Prevent zero only lines from being emptied
  • Loading branch information
markstory committed Nov 18, 2014
2 parents ddc3eee + bae556e commit 30f8073
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -1359,7 +1359,7 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
$cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST);

foreach ($lines as $line) {
if (empty($line)) {
if (empty($line) && $line !== '0') {
$formatted[] = '';
continue;
}
Expand Down
19 changes: 19 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -2416,6 +2416,25 @@ public function testWrapForJapaneseEncoding() {
$this->assertEquals($expected, $result['message']);
}

/**
* testZeroOnlyLinesNotBeingEmptied()
*
* @return void
*/
public function testZeroOnlyLinesNotBeingEmptied() {
$message = "Lorem\r\n0\r\n0\r\nipsum";

$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 = "{$message}\r\n\r\n";
$this->assertEquals($expected, $result['message']);
}

/**
* CakeEmailTest::assertLineLengths()
*
Expand Down

0 comments on commit 30f8073

Please sign in to comment.