Skip to content

Commit

Permalink
Check line length to account for fence post.
Browse files Browse the repository at this point in the history
When we have exactly 998 bytes CakeEmail should not emit an error.

Refs #5948
  • Loading branch information
markstory committed Feb 25, 2015
1 parent ef82096 commit b80a894
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Cake/Network/Email/CakeEmail.php
Expand Up @@ -1421,7 +1421,7 @@ protected function _wrap($message, $wrapLength = CakeEmail::LINE_LENGTH_MUST) {
$tmpLine .= $char;
$tmpLineLength++;
if ($tmpLineLength === $wrapLength) {
$nextChar = $line[$i + 1];
$nextChar = isset($line[$i + 1]) ? $line[$i + 1] : '';
if ($nextChar === ' ' || $nextChar === '<') {
$formatted[] = trim($tmpLine);
$tmpLine = '';
Expand Down
19 changes: 19 additions & 0 deletions lib/Cake/Test/Case/Network/Email/CakeEmailTest.php
Expand Up @@ -2435,6 +2435,25 @@ public function testZeroOnlyLinesNotBeingEmptied() {
$this->assertEquals($expected, $result['message']);
}

/**
* Test that really long lines don't cause errors.
*
* @return void
*/
public function testReallyLongLine() {
$this->CakeEmail->reset();
$this->CakeEmail->config(array('empty'));
$this->CakeEmail->transport('Debug');
$this->CakeEmail->from('cake@cakephp.org');
$this->CakeEmail->to('cake@cakephp.org');
$this->CakeEmail->subject('Wordwrap Test');
$this->CakeEmail->emailFormat('html');
$this->CakeEmail->template('long_line', null);
$result = $this->CakeEmail->send();
$this->assertContains('<a>', $result['message'], 'First bits are included');
$this->assertContains('x', $result['message'], 'Last byte are included');
}

/**
* CakeEmailTest::assertLineLengths()
*
Expand Down
14 changes: 14 additions & 0 deletions lib/Cake/Test/test_app/View/Emails/html/long_line.ctp
@@ -0,0 +1,14 @@
<?php
echo '<a>34567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'12345678901234567890123456789012345678901234567890123456789012345678901234567890' .
'1234567890123456789012345678901234567890123456x';

0 comments on commit b80a894

Please sign in to comment.