From 58081593e9d37eb17c687e6ab8a0eb3ec3d36d8a Mon Sep 17 00:00:00 2001 From: David Rothstein Date: Wed, 25 Dec 2013 16:49:17 -0500 Subject: Issue #310315 by superspring, justafish, naxoc, Waltemath | fonant: drupal_wrap_mail() strips trailing blanks from standard hyphen-hyphen-space-newline e-mail signature separator. --- modules/simpletest/tests/mail.test | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'modules/simpletest/tests') diff --git a/modules/simpletest/tests/mail.test b/modules/simpletest/tests/mail.test index 8024010ab..70a43cb45 100644 --- a/modules/simpletest/tests/mail.test +++ b/modules/simpletest/tests/mail.test @@ -267,6 +267,31 @@ class DrupalHtmlToTextTestCase extends DrupalWebTestCase { ); } + /** + * Tests that drupal_wrap_mail() removes trailing whitespace before newlines. + */ + function testDrupalHtmltoTextRemoveTrailingWhitespace() { + $text = "Hi there! \nHerp Derp"; + $mail_lines = explode("\n", drupal_wrap_mail($text)); + $this->assertNotEqual(" ", substr($mail_lines[0], -1), 'Trailing whitespace removed.'); + } + + /** + * Tests drupal_wrap_mail() retains whitespace from Usenet style signatures. + * + * 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." + */ + function testDrupalHtmltoTextUsenetSignature() { + $text = "Hi there!\n-- \nHerp Derp"; + $mail_lines = explode("\n", drupal_wrap_mail($text)); + $this->assertEqual("-- ", $mail_lines[1], 'Trailing whitespace not removed for dash-dash-space signatures.'); + + $text = "Hi there!\n-- \nHerp Derp"; + $mail_lines = explode("\n", drupal_wrap_mail($text)); + $this->assertEqual("--", $mail_lines[1], 'Trailing whitespace removed for incorrect dash-dash-space signatures.'); + } + /** * Test that whitespace is collapsed. */ -- cgit v1.2.3