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

<?php
$n
= max(0, 79 - (strlen($text) - $p) - strlen($prefix));
?>

to
<?php
$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:

<?php
$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

Files: 
CommentFileSizeAuthor
#5 line_padding-923510-5.patch6.58 KBShnapoo
PASSED: [[SimpleTest]]: [MySQL] 52,191 pass(es).
[ View ]
#2 line_padding-923510-1.patch534 bytesShnapoo
FAILED: [[SimpleTest]]: [MySQL] 37,028 pass(es), 12 fail(s), and 0 exception(s).
[ View ]

Comments

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.

Status:Active» Reviewed & tested by the community
StatusFileSize
new534 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.

Assigned:Unassigned» Shnapoo

Status:Needs work» Reviewed & tested by the community
StatusFileSize
new6.58 KB
PASSED: [[SimpleTest]]: [MySQL] 52,191 pass(es).
[ 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.

Status:Reviewed & tested by the community» Needs review

Assigned:Shnapoo» Unassigned

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.

Status:Reviewed & tested by the community» Needs review

Please don't mark your own patches RTBC.

Please don't delay trivial fixes.

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."

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

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

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.

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