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

Bug #7561 Mail_mimePart::_quotedPrintableEncode() misbehavior with mbstring overload
Submitted: 2006-05-05 09:23 UTC
From: php at diptyque dot net Assigned: cipri
Status: Closed Package: Mail_Mime (version 1.3.1)
PHP Version: Irrelevant OS: FreeBSD
Roadmaps: 1.4.0, 1.4.0a1    
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes. If this is not your bug, you can add a comment by following this link. If this is your bug, but you forgot your password, you can retrieve your password here.
2007-05-05 15:09 UTC
Bug Type:
From: php at diptyque dot net
New email:
PHP Version: Package Version: OS:


 [2006-05-05 09:23 UTC] php at diptyque dot net (MichaĆ«l Guitton)
Description: ------------ Mail_mimePart::_quotedPrintableEncode() does not properly encode multi-byte characters when mbstring overload is enabled: it only encodes the first byte and skips any following byte(s) ; php.ini Multi-byte string setup mbstring.language = Neutral; (UTF-8) mbstring.func_overload = 6; see [1] mbstring.internal_encoding = UTF-8 mbstring.http_output = UTF-8 [1] ( rload) Test script: --------------- =begin TEST <?php require_once 'Mail/mimePart.php'; // string is UTF-8 encoded $input = "Micha\xC3\xABl \xC3\x89ric St\xC3\xA9phane"; $rv = Mail_mimePart::_quotedPrintableEncode($input); echo $rv, "\n"; ?> =end TEST A multi-byte string agnostic patch: =begin DIFF diff -u mimePart.php.bak mimePart.php --- mimePart.php.bak Thu Jan 19 13:09:40 2006 +++ mimePart.php Tue Apr 25 11:19:34 2006 @@ -318,11 +318,12 @@ while(list(, $line) = each($lines)){ - $linlen = strlen($line); + $line = preg_split('//', $line, -1, PREG_SPLIT_NO_EMPTY); + $linlen = count($line); $newline = ''; for ($i = 0; $i < $linlen; $i++) { - $char = substr($line, $i, 1); + $char = $line[$i]; $dec = ord($char); if (($dec == 32) AND ($i == ($linlen - 1))){ // convert space at eol only =end DIFF Expected result: ---------------- Micha=C3=ABl =C3=89ric St=C3=A9phane Actual result: -------------- Micha=C3l =C3ric St=C3phane


 [2006-06-07 18:06 UTC] gauthierm (Michael Gauthier)
I've verified this bug as well. Here is an alternative patch that doesn't use preg:
 [2006-12-03 11:58 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.
 [2007-05-05 15:09 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 Fixed in 1.4.0