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

Bug #8223 Incorrectly encoded quoted-printable headers
Submitted: 2006-07-15 01:54 UTC
From: nrf Assigned: cipri
Status: Closed Package: Mail_Mime (version CVS)
PHP Version: 5.1.4 OS:
Roadmaps: 1.4.0, 1.4.0a1    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 42 - 39 = ?

 
 [2006-07-15 01:54 UTC] nrf (Nathan Fredrickson)
Description: ------------ _encodeHeaders() incorrectly splits long quoted-printable headers into multiple lines. The first line is too long since $maxLength1stLine is not used. Secondly, line breaks occur within encoded characters. The attached patch fixes both issues. Test script: --------------- Index: mime.php =================================================================== RCS file: /repository/pear/Mail_Mime/mime.php,v retrieving revision 1.56 diff -u -p -r1.56 mime.php --- mime.php 18 May 2006 23:05:14 -0000 1.56 +++ mime.php 15 Jul 2006 01:48:16 -0000 @@ -849,8 +849,8 @@ class Mail_mime ); //This regexp will break QP-encoded text at every $maxLength //but will not break any encoded letters. - $reg1st = "|(.{0,$maxLength})[^\=]|"; - $reg2nd = "|(.{0,$maxLength})[^\=]|"; + $reg1st = "|(.{0,$maxLength1stLine})[0-9A-F][0-9A-F]|"; + $reg2nd = "|(.{0,$maxLength})[0-9A-F][0-9A-F]|"; break; } //Begin with the regexp for the first line.

Comments

 [2006-10-18 22:23 UTC] cipri (Cipriano Groenendal)
Do you have a example where this happens, or is this just from reading the code? I tested this code quite a bit and never ran into any problems. As such, a test case'd be great :)
 [2006-10-19 18:25 UTC] nrf at php dot net (Nathan Fredrickson)
I was able to reproduce part of this bug. To reproduce iconv_mime_encode() has to be unavailable. The following test script demonstrates the problem. The first encoded line is too long since $maxLength1stLine is not used to account for the length of the header field name "Subject: ". Test script: -------------- require_once 'Mail/mime.php'; $mime = new Mail_mime("\n"); $headers['Subject'] = 'An extra long subject string with “encodable” characters that will exceed the max line length.'; /* Note that the word encodable is surrounded in curly * quotes, UTF-8 characters 0x201C and 0x201D. */ $params = array(); $params['head_charset'] = 'UTF-8'; $params['head_encoding'] = 'quoted-printable'; $body = $mime->get($params); $headers = $mime->headers($headers); echo $headers['Subject'], "\n"; Expected results: ----------------- =?UTF-8?Q?An=20extra=20long=20subject=20string=20with=20=E2=80=9C?= =?UTF-8?Q?encodable=E2=80=9D=20characters=20that=20will=20exceed=20the=20?= =?UTF-8?Q?max=20line=20length.?= Actual results: --------------- =?UTF-8?Q?An_extra_long_subject_string_with_=E2=80=9Cencodable=E2?= =?UTF-8?Q?=80=9D_characters_that_will_exceed_the_max_line_length.?= Updated patch: -------------- Index: mime.php =================================================================== RCS file: /repository/pear/Mail_Mime/mime.php,v retrieving revision 1.56 diff -u -p -r1.56 mime.php --- mime.php 18 May 2006 23:05:14 -0000 1.56 +++ mime.php 19 Oct 2006 18:11:53 -0000 @@ -849,7 +849,7 @@ class Mail_mime ); //This regexp will break QP-encoded text at every $maxLength //but will not break any encoded letters. - $reg1st = "|(.{0,$maxLength})[^\=]|"; + $reg1st = "|(.{0,$maxLength1stLine})[^\=]|"; $reg2nd = "|(.{0,$maxLength})[^\=]|"; break; }
 [2006-10-19 18:35 UTC] nrf at php dot net (Nathan Fredrickson)
Sorry, i mixed up my result cases above. The expected/actual results should be the following. Expected results: ----------------- =?UTF-8?Q?An_extra_long_subject_string_with_=E2=80=9Cencodable=E2?= =?UTF-8?Q?=80=9D_characters_that_will_exceed_the_max_line_length.?= Actual results: --------------- =?UTF-8?Q?An_extra_long_subject_string_with_=E2=80=9Cencodable=E2=80=9D_?= =?UTF-8?Q?characters_that_will_exceed_the_max_line_length.?=
 [2006-12-03 16:32 UTC] cipri (Cipriano Groenendal)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net 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.
 [2007-05-05 15:08 UTC] cipri (Cipriano Groenendal)
Thank you for your bug report. This issue has been fixed in the latest released version of the package, which you can download at http://pear.php.net/get/Mail_Mime Fixed in 1.4.0