mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Processing was simplified when a length of one line was smaller than CakeEmail::LINE_LENGTH_MUST
This commit is contained in:
parent
631082a2a4
commit
05473fe7d0
2 changed files with 73 additions and 53 deletions
|
@ -1254,7 +1254,11 @@ class CakeEmail {
|
|||
$formatted[] = '';
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/<[a-z]+.+>/i', $line)) {
|
||||
if (strlen($line) < $wrapLength) {
|
||||
$formatted[] = $line;
|
||||
continue;
|
||||
}
|
||||
if (!preg_match('/<[a-z]+.*>/i', $line)) {
|
||||
$formatted = array_merge(
|
||||
$formatted,
|
||||
explode("\n", wordwrap($line, $wrapLength, "\n"))
|
||||
|
|
|
@ -1622,58 +1622,6 @@ class CakeEmailTest extends CakeTestCase {
|
|||
$this->assertContains('ってテーブルを作ってやってたらう', $result['message']);
|
||||
}
|
||||
|
||||
public function testWrapLongLine() {
|
||||
$message = '<a href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "</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('x', CakeEmail::LINE_LENGTH_MUST) . "\r\n</a>\r\n\r\n";
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
}
|
||||
|
||||
public function testWrapIncludeTag() {
|
||||
$message = '<a href="http://cakephp.org">CakePHP</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 = "{$message}\r\n\r\n";
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
|
||||
$message = 'foo<bar';
|
||||
|
||||
$result = $this->CakeEmail->send($message);
|
||||
$expected = "{$message}\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
|
||||
*
|
||||
|
@ -1918,4 +1866,72 @@ class CakeEmailTest extends CakeTestCase {
|
|||
return $email;
|
||||
}
|
||||
|
||||
public function testWrapLongLine() {
|
||||
$message = '<a href="http://cakephp.org">' . str_repeat('x', CakeEmail::LINE_LENGTH_MUST) . "</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('x', CakeEmail::LINE_LENGTH_MUST) . "\r\n</a>\r\n\r\n";
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
|
||||
$str1 = "a ";
|
||||
$str2 = " b";
|
||||
$len = strlen($str1) + strlen($str2);
|
||||
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $len - 1) . $str2;
|
||||
|
||||
$result = $this->CakeEmail->send($message);
|
||||
$expected = "{$message}\r\n\r\n";
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
|
||||
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $len) . $str2;
|
||||
|
||||
$result = $this->CakeEmail->send($message);
|
||||
$expected = "{$message}\r\n\r\n";
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
|
||||
$message = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $len + 1) . $str2;
|
||||
|
||||
$result = $this->CakeEmail->send($message);
|
||||
$expected = $str1 . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $len + 1) . sprintf("\r\n%s\r\n\r\n", trim($str2));
|
||||
$this->assertEquals($expected, $result['message']);
|
||||
}
|
||||
|
||||
public function testWrapIncludeLessThanSign() {
|
||||
$str = 'foo<bar';
|
||||
$len = strlen($str);
|
||||
$message = $str . str_repeat('x', CakeEmail::LINE_LENGTH_MUST - $len + 1);
|
||||
|
||||
$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']);
|
||||
}
|
||||
|
||||
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']);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue