PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Mail » Mail_Mime » Bug #5485

Spurious carriage returns mess up encoding

Details

Submitted2005-09-22 03:31 UTC
Fromgsstark at mit dot edu
Assignedcipri
StatusClosed
PackageMail_Mime
PHP Version4.3.10
OSLinux
Roadmaps(Not assigned)

Comments

[2005-09-22 03:31 UTC] gsstark at mit dot edu

Description:
------------
When I send mail with send() The resulting email has
linefeeds at the end of every line.

Since the mail constructed by Mail_mime is in quoted
printable encoding (even though there are no characters
that wouldn't fit in 7bit encoding just fine!) this causes
a problem. Any long line is continued in quoted-printable
with an = character at the end of the line. The linefeed
messes that up and instead people report spurious spaces
being displayed in the middle of words whereever these
continuations occurred.

Test script:
---------------
$mime = new Mail_mime();
$mime->setHTMLBody("...long multiline text..."));
$body = $mime->get();
$head = $mime->headers();
$mailer = Mail::factory('mail');
$mailer->send($recipients, $head, $body);

Expected result:
----------------
<b>Update Registration!</b><br>

Change your email address, password or any of your account
information. <br>
<a href="http://www.example.com/register.php">Click here
to Update Registration!</a>

Actual result:
--------------
<b>Update Registration!</b><br>^M
^M
Change your email address, password or any of your account
information. <br=^M
>^M
<a href=3D"http://www.example.com/register.php">Click here
to Update Regist=^M
ration!</a>^M

[2005-09-22 16:08 UTC] gsstark at mit dot edu

I guess I mean carriage returns, not linefeeds

[2006-06-27 19:41 UTC] joliver at gmx dot at

The problem is line 314 in mimePart.php:

function _quotedPrintableEncode($input , $line_max = 76)
{
$lines = preg_split("/\r?\n/", $input);

if $input has \n instead of \r\n, no carriage return is
found, and unnessessary additional line breaks are
inserted.

[2006-06-27 19:58 UTC] joliver at gmx dot at

Please ignore/remove my last posting, the code is ok.

(I had this problem with a very old version of mail_mime,
with the current version everything seems to be fine).