Skip to content
Permalink
Browse files

Check line length to account for fence post.

When we have exactly 998 bytes CakeEmail should not emit an error.

Refs #5948
  • Loading branch information...
markstory committed Feb 24, 2015
1 parent ef82096 commit b80a8947d7f2cc0396a256ecc711b10961b4f8ae
@@ -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 = '';
@@ -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()
*
@@ -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.
You can’t perform that action at this time.