function HtmlToTextTest::testUsenetSignature

Same name and namespace in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php \Drupal\Tests\system\Functional\Mail\HtmlToTextTest::testUsenetSignature()
  2. 10 core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testUsenetSignature()
  3. 11.x core/modules/system/tests/src/Unit/Mail/HtmlToTextTest.php \Drupal\Tests\system\Unit\Mail\HtmlToTextTest::testUsenetSignature()

Tests that trailing whitespace from Usenet style signatures is not removed.

RFC 3676 says, "This is a special case; an (optionally quoted or quoted and stuffed) line consisting of DASH DASH SP is neither fixed nor flowed."

See also

\Drupal\Core\Mail\MailFormatHelper::wrapMail()

File

core/modules/system/tests/src/Functional/Mail/HtmlToTextTest.php, line 366

Class

HtmlToTextTest
Tests for <a href="/api/drupal/core%21lib%21Drupal%21Core%21Mail%21MailFormatHelper.php/function/MailFormatHelper%3A%3AhtmlToText/9" title="Transforms an HTML string into plain text, preserving its structure." class="local">\Drupal\Core\Mail\MailFormatHelper::htmlToText</a>().

Namespace

Drupal\Tests\system\Functional\Mail

Code

public function testUsenetSignature() {
    $text = "Hi there!\n-- \nEarth";
    $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
    $this->assertEquals("-- ", $mail_lines[1], 'Trailing whitespace not removed for dash-dash-space signatures.');
    $text = "Hi there!\n--  \nEarth";
    $mail_lines = explode("\n", MailFormatHelper::wrapMail($text));
    $this->assertEquals("--", $mail_lines[1], 'Trailing whitespace removed for incorrect dash-dash-space signatures.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.