Issue #2414019 by Hardik_Patel_12, mpp, swelljoe, jungle, quietone, mohit_aghera: Use of strtoupper for URLs in MailFormatHelper.php's htmlToText() method triggers spam filters

merge-requests/539/head
catch 2021-04-09 09:30:26 +01:00
parent 6e137b34e8
commit 3d23f22953
2 changed files with 8 additions and 17 deletions

View File

@ -142,8 +142,6 @@ class MailFormatHelper {
// required).
// Odd/even counter (tag or no tag).
$tag = FALSE;
// Case conversion function.
$casing = NULL;
$output = '';
// All current indentation string chunks.
$indent = [];
@ -221,17 +219,14 @@ class MailFormatHelper {
// Fancy headers.
case 'h1':
$indent[] = '======== ';
$casing = 'mb_strtoupper';
break;
case 'h2':
$indent[] = '-------- ';
$casing = 'mb_strtoupper';
break;
case '/h1':
case '/h2':
$casing = NULL;
// Pad the line with dashes.
$output = static::htmlToTextPad($output, ($tagname == '/h1') ? '=' : '-', ' ');
array_pop($indent);
@ -266,10 +261,6 @@ class MailFormatHelper {
// See if there is something waiting to be output.
if (isset($chunk)) {
// Apply any necessary case conversion.
if (isset($casing)) {
$chunk = call_user_func($casing, $chunk);
}
$line_endings = Settings::get('mail_line_endings', PHP_EOL);
// Format it and apply the current indentation.
$output .= static::wrapMail($chunk, implode('', $indent)) . $line_endings;

View File

@ -85,10 +85,10 @@ class HtmlToTextTest extends BrowserTestBase {
// @todo The <div> tag is currently not supported.
'<div>Drupal</div><div>Drupal</div>' => "DrupalDrupal\n",
'<em>Drupal</em>' => "/Drupal/\n",
'<h1>Drupal</h1>' => "======== DRUPAL ==============================================================\n\n",
'<h1>Drupal</h1><p>Drupal</p>' => "======== DRUPAL ==============================================================\n\nDrupal\n\n",
'<h2>Drupal</h2>' => "-------- DRUPAL --------------------------------------------------------------\n\n",
'<h2>Drupal</h2><p>Drupal</p>' => "-------- DRUPAL --------------------------------------------------------------\n\nDrupal\n\n",
'<h1>Drupal</h1>' => "======== Drupal ==============================================================\n\n",
'<h1>Drupal</h1><p>Drupal</p>' => "======== Drupal ==============================================================\n\nDrupal\n\n",
'<h2>Drupal</h2>' => "-------- Drupal --------------------------------------------------------------\n\n",
'<h2>Drupal</h2><p>Drupal</p>' => "-------- Drupal --------------------------------------------------------------\n\nDrupal\n\n",
'<h3>Drupal</h3>' => ".... Drupal\n\n",
'<h3>Drupal</h3><p>Drupal</p>' => ".... Drupal\n\nDrupal\n\n",
'<h4>Drupal</h4>' => ".. Drupal\n\n",
@ -247,21 +247,21 @@ EOT;
public function testHeaderSeparation() {
$html = 'Drupal<h1>Drupal</h1>Drupal';
// @todo There should be more space above the header than below it.
$text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n";
$text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n";
$this->assertHtmlToText($html, $text,
'Text before and after <h1> tag');
$html = '<p>Drupal</p><h1>Drupal</h1>Drupal';
// @todo There should be more space above the header than below it.
$text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n";
$text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n";
$this->assertHtmlToText($html, $text,
'Paragraph before and text after <h1> tag');
$html = 'Drupal<h1>Drupal</h1><p>Drupal</p>';
// @todo There should be more space above the header than below it.
$text = "Drupal\n======== DRUPAL ==============================================================\n\nDrupal\n\n";
$text = "Drupal\n======== Drupal ==============================================================\n\nDrupal\n\n";
$this->assertHtmlToText($html, $text,
'Text before and paragraph after <h1> tag');
$html = '<p>Drupal</p><h1>Drupal</h1><p>Drupal</p>';
$text = "Drupal\n\n======== DRUPAL ==============================================================\n\nDrupal\n\n";
$text = "Drupal\n\n======== Drupal ==============================================================\n\nDrupal\n\n";
$this->assertHtmlToText($html, $text,
'Paragraph before and after <h1> tag');
}