\Drupal\Core\Mail\MailFormatHelper::htmlToTextPad() is not RFC 2822 compliant

Created on 26 September 2010, over 14 years ago
Updated 16 March 2023, almost 2 years ago

Problem/Motivation

I'm using Simplenews + cck + Nodereference + Mimemail for sending newsletters in plain text (Mimemail because a custom module uses it to attach files to other mails).
Everything works fine except the transformation "html mail" -> "plain mail".

Given:
<h2>Band name</h2>

Result:

-------- Band name  
-----------------------------------------------------------

As you can see there is a linebreak in the headline. I figured out that the core helper function _drupal_html_to_text_pad() adds one '-' too much. After changing line

$n = max(0, 79 - (strlen($text) - $p) - strlen($prefix));

to

$n = max(0, 78 - (strlen($text) - $p) - strlen($prefix));

everything works fine.

Are there other people out there with this problem? If not - do you have any ideas what's going wrong?

A little debug information:

$n = max(0, 79 - (strlen($text) - $p) - strlen($prefix));
  dpm(strlen($text)); // 783
  dpm($p); // 766
  dpm(strlen($prefix)); // 1
  dpm($n); // 61

PHP Version: 5.2.6-1+lenny9

Steps to reproduce

TBA

Proposed resolution

TBA

Remaining tasks

TBA

User interface changes

API changes

Data model changes

Release notes snippet

🐛 Bug report
Status

Needs work

Version

10.1

Component
Mail 

Last updated 19 days ago

No maintainer
Created by

🇩🇪Germany haggins

Live updates comments and jobs are added and updated live.
  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024