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

CommentFileSizeAuthor
#5 line_padding-923510-5.patch6.58 KBShnapoo
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch line_padding-923510-5.patch. Unable to apply patch. See the log in the details link for more information. View
#2 line_padding-923510-1.patch534 bytesShnapoo
FAILED: [[SimpleTest]]: [MySQL] 37,028 pass(es), 12 fail(s), and 0 exception(s). View
Members fund testing for the Drupal project. Drupal Association Learn more

Comments

Shnapoo’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.

Shnapoo’s picture

Status: Active » Reviewed & tested by the community
FileSize
534 bytes
FAILED: [[SimpleTest]]: [MySQL] 37,028 pass(es), 12 fail(s), and 0 exception(s). View

Status: Reviewed & tested by the community » Needs work

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

Shnapoo’s picture

Assigned: Unassigned » Shnapoo
Shnapoo’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
6.58 KB
FAILED: [[SimpleTest]]: [PHP 5.4 MySQL] Unable to apply patch line_padding-923510-5.patch. Unable to apply patch. See the log in the details link for more information. View

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.

Shnapoo’s picture

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

Assigned: Shnapoo » Unassigned
Shnapoo’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.

Shnapoo’s picture

Please don't delay trivial fixes.

Shnapoo’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.

nbz’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.

nbz’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.