function HtmlToTextTest::testVeryLongLineWrap
Same name in other branches
- 9 core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testVeryLongLineWrap()
- 8.9.x core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testVeryLongLineWrap()
- 10 core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testVeryLongLineWrap()
Tests \Drupal\Core\Mail\MailFormatHelper::htmlToText() wrapping.
RFC 3676 says, "The Text/Plain media type is the lowest common denominator of Internet email, with lines of no more than 998 characters."
RFC 2046 says, "SMTP [RFC-821] allows a maximum of 998 octets before the next CRLF sequence."
RFC 821 says, "The maximum total length of a text line including the <CRLF> is 1000 characters."
File
-
core/
modules/ system/ tests/ src/ Unit/ Mail/ HtmlToTextTest.php, line 338
Class
Namespace
Drupal\Tests\system\Unit\MailCode
public function testVeryLongLineWrap() : void {
$input = 'Drupal<br /><p>' . str_repeat('x', 2100) . '</p><br />Drupal';
$output = MailFormatHelper::htmlToText($input);
$eol = Settings::get('mail_line_endings', PHP_EOL);
$maximum_line_length = 0;
foreach (explode($eol, $output) as $line) {
// We must use strlen() rather than mb_strlen() in order to count octets
// rather than characters.
$maximum_line_length = max($maximum_line_length, strlen($line . $eol));
}
// Verify that the maximum line length found was less than or equal to 1000
// characters as per RFC 821.
$this->assertLessThanOrEqual(1000, $maximum_line_length);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.