From bae556e73fc18fbf081eba7862fb3767be1a5e2a Mon Sep 17 00:00:00 2001 From: ndm2 Date: Tue, 18 Nov 2014 17:26:31 +0100 Subject: [PATCH] Prevent zero only lines from being emptied --- lib/Cake/Network/Email/CakeEmail.php | 2 +- .../Test/Case/Network/Email/CakeEmailTest.php | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/Cake/Network/Email/CakeEmail.php b/lib/Cake/Network/Email/CakeEmail.php index eb5b3c9b7..61dc597b3 100644 --- a/lib/Cake/Network/Email/CakeEmail.php +++ b/lib/Cake/Network/Email/CakeEmail.php @@ -1359,7 +1359,7 @@ class CakeEmail { $cut = ($wrapLength == CakeEmail::LINE_LENGTH_MUST); foreach ($lines as $line) { - if (empty($line)) { + if (empty($line) && $line !== '0') { $formatted[] = ''; continue; } diff --git a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php index 23dd78bd6..1dc125fea 100644 --- a/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php +++ b/lib/Cake/Test/Case/Network/Email/CakeEmailTest.php @@ -2416,6 +2416,25 @@ HTML; $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() *