Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.10.2

Bug #11731 Full stops after soft line breaks are not encoded
Submitted: 2007-08-01 01:51 UTC
From: squiz Assigned: cipri
Status: Closed Package: Mail_Mime (version 1.5.2)
PHP Version: 4.4.2 OS: Debian
Roadmaps: 1.5.3    

 [2007-08-01 01:51 UTC] squiz (Greg Sherwood)
Description: ------------ There was a patch added to Mail_mime 1.4.0, that encoded full-stops at the beginning of a line to "=2E" when encoding to quoted-printable (bug #9722). The patch given in that bug is effective for hard line breaks added by the user, however it does not work with soft line breaks (end-of-line '=') that are added by the encoding function (to ensure that lines are less than the length limit, usually 76 characters). The piece of code that checks this is called at the start of lines started by the user, but is never called when a soft line break is created - the character test has already been done before the line break has been made, and by the next loop, it is too late to check because the character has already been added. The fix could be done in one of two ways: checking specifically for a full-stop again when creating a soft line break, or moving this check to after where a soft line break is created, just before where the character is added to the line. The proposed patch takes the latter option. Test script: --------------- <?php require_once 'Mail/mimePart.php'; // Second full stop will be at the start of the second line after quoted-printable // encoding (full stop '=2E' + 72 characters + line-continuation '=' = 76) $text = '.123456789012345678901234567890123456789012345678901234567890123456789012.3456'; $params = Array( 'content_type' => 'text/plain', 'encoding' => 'quoted-printable', ); $mimePart =& new Mail_mimePart($text, $params); $encoded = $mimePart->encode(); echo $encoded['body']; ?> Expected result: ---------------- =2E123456789012345678901234567890123456789012345678901234567890123456789012= =2E3456 Full-stops at the start of both 'hard' and 'soft' starts of lines are escaped. Actual result: -------------- =2E123456789012345678901234567890123456789012345678901234567890123456789012= .3456 The full-stop on the 'hard' start of line is escaped, however the one on the 'soft' new line created by _quotedPrintableEncode() is not.


 [2007-08-01 02:00 UTC] squiz (Greg Sherwood)
I can't submit a patch for some reason, so here it is: --- /home/lwright/Mail_Mime-1.5.2/mimePart.php 2007-06-22 05:10:11.000000000 +1000 +++ ./mimePart.php 2007-08-01 11:49:39.000000000 +1000 @@ -357,16 +357,19 @@ ; // Do nothing if a tab. } elseif (($dec == 61) OR ($dec < 32 ) OR ($dec > 126)) { $char = $escape . strtoupper(sprintf('%02s', dechex($dec))); - } elseif (($dec == 46) AND ($newline == '')) { - //Bug #9722: convert full-stop at bol - //Some Windows servers need this, won't break anything (cipri) - $char = '=2E'; } if ((strlen($newline) + strlen($char)) >= $line_max) { // MAIL_MIMEPART_CRLF is not counted $output .= $newline . $escape . $eol; // soft line break; " =\r\n" is okay $newline = ''; } + + if (($dec == 46) AND ($newline == '')) { + //Bug #9722: convert full-stop at bol + //Some Windows servers need this, won't break anything (cipri) + $char = '=2E'; + } + $newline .= $char; } // end of for $output .= $newline . $eol;
 [2007-10-06 12:50 UTC] cipri (Cipriano Groenendal)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on by the end of next Sunday (CET). If this was a problem with the website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. Thanks for the bugreport, I've fixed it by including the line_max check on the ($dec == 46) line, as $char can't always accurately be used at that point in your patch :)