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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Anonymous’s picture

Title: Plain Mail: Pad the last line with the given character - Failure in core function? » _drupal_html_to_text_pad() not RFC 2822 compliant
Version: 6.19 » 8.x-dev

RFC 2822:

There are two limits that this standard places on the number of
characters in a line. Each line of characters MUST be no more than
998 characters, and SHOULD be no more than 78 characters, excluding
the CRLF.

_drupal_html_to_text_pad() pads lines to 79 characters. This causes unintended line breaks in many e-mail applications.

Haggins has provided the proper fix above.

Anonymous’s picture

Status: Active » Reviewed & tested by the community
FileSize
534 bytes

Status: Reviewed & tested by the community » Needs work

The last submitted patch, line_padding-923510-1.patch, failed testing.

Anonymous’s picture

Assigned: Unassigned »
Anonymous’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.58 KB

Modifying tests accordingly. First time I do this, but makes sense to me, somehow. Hope I can get it to work. Please excuse me spamming this issue.

Anonymous’s picture

Status: Reviewed & tested by the community » Needs review
Anonymous’s picture

Assigned: » Unassigned
Anonymous’s picture

Status: Needs review » Reviewed & tested by the community

I send thousands of Simplenew newsletters per month using this fix. It is simple and it works. No need to delay.

Should be backported to D6 and D7 ASAP. A chance to prove the Drupal community is interested in common standards.

webchick’s picture

Status: Reviewed & tested by the community » Needs review

Please don't mark your own patches RTBC.

Anonymous’s picture

Please don't delay trivial fixes.

Anonymous’s picture

Newsletters of Drupal.org are affected. Received today:

* Advisory ID: [...]
* Project: [...]
* Version: 7.x
* Date: 2013-February-20
* Security risk: Moderately critical [2]
* Exploitable from: Remote
* Vulnerability: Cross Site Scripting

-------- DESCRIPTION
---------------------------------------------------------

[...]

"The shoemaker's son always goes barefoot."

haggins’s picture

Version: 8.x-dev » 7.x-dev

Why is this a 8.x issue? D7 is affected as well.

NaheemSays’s picture

Version: 7.x-dev » 8.x-dev

Development is done on a trickle down basis where new development/bug fixes are developed for the latest version and then backported to supported versions.

So moving back to 8.x - when fixed there, it can then be backported to 7.x.

@ comment 10 - there is a process that is followed because even what sometimes seems trivial can cause problems and have repercussions, so unless it is a security issue (and even then), there needs to be a process followed, which some times may seem like overkill, but it is there for a reason and has developed out of past development experience.

NaheemSays’s picture

#5: line_padding-923510-5.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 5: line_padding-923510-5.patch, failed testing.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

jungle’s picture

Title: _drupal_html_to_text_pad() not RFC 2822 compliant » \Drupal\Core\Mail\MailFormatHelper::htmlToTextPad() is not RFC 2822 compliant
Version: 8.9.x-dev » 9.1.x-dev
Issue summary: View changes
Issue tags: +Bug Smash Initiative, +Needs issue summary update
  1. Changing the title, _drupal_html_to_text_pad() does not exist anymore, and changing the target version to the current dev branch.
  2. Tagging "Bug Smash Initiative"
  3. Tagging "Needs issue summary update" and further checking to see if the issue still exists.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes

I tested on Drupal 10.1.x, using the instructions in the issue summary and reproduced the problem.

Rishabh Vishwakarma’s picture

Added patch for 10.1.x as the problem can be reproduced.

Rishabh Vishwakarma’s picture

Status: Needs work » Needs review
Santosh_Verma’s picture

I have tested patch #32, applied successfully.

smustgrave’s picture

Status: Needs review » Needs work

Still needs an issue summary update for the TBD sections.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.