From: Adam Harvey Date: Tue, 4 May 2010 11:56:59 +0000 (+0000) Subject: Fix for bug #48289 (iconv_mime_encode() quoted-printable scheme is broken). X-Git-Tag: php-5.3.3RC1~199 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=73ddb796137d32dc8586cb27e86a7599b138b3cf;p=php Fix for bug #48289 (iconv_mime_encode() quoted-printable scheme is broken). Thanks to Hiroaki Kawai for the original patch. --- diff --git a/NEWS b/NEWS index 524060d8bc..11a0b50794 100644 --- a/NEWS +++ b/NEWS @@ -131,6 +131,8 @@ PHP NEWS (yoarvi@gmail.com, Derick) - Fixed bug #48983 (DomDocument : saveHTMLFile wrong charset). (Rob) - Fixed bug #48902 (Timezone database fallback map is outdated). (Derick) +- Fixed bug #48289 (iconv_mime_encode() quoted-printable scheme is broken). + (Adam, patch from hiroaki dot kawai at gmail dot com). - Fixed bug #48781 (Cyclical garbage collector memory leak). (Dmitry) - Fixed bug #48361 (SplFileInfo::getPathInfo should return the parent dir). (Etienne) diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c index 9ab771889a..7f90d6df5d 100644 --- a/ext/iconv/iconv.c +++ b/ext/iconv/iconv.c @@ -1206,7 +1206,7 @@ static php_iconv_err_t _php_iconv_mime_encode(smart_str *pretval, const char *fn prev_in_left = ini_in_left = in_left; ini_in_p = in_p; - for (out_size = char_cnt; out_size > 0;) { + for (out_size = (char_cnt - 2) / 3; out_size > 0;) { size_t prev_out_left; nbytes_required = 0; diff --git a/ext/iconv/tests/bug48289.phpt b/ext/iconv/tests/bug48289.phpt new file mode 100644 index 0000000000..fc2cd360b6 --- /dev/null +++ b/ext/iconv/tests/bug48289.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #48289 (iconv_mime_encode() quoted-printable scheme is broken) +--SKIPIF-- + +--FILE-- + 'Q', + 'input-charset' => 'UTF-8', + 'output-charset' => 'UTF-8', + 'line-length' => 30, +); + +echo iconv_mime_encode('Subject', $text, $options); +--EXPECT-- +Subject: =?UTF-8?Q?=E3=83=86?= + =?UTF-8?Q?=E3=82=B9?= + =?UTF-8?Q?=E3=83=88?= + =?UTF-8?Q?=E3=83=86?= + =?UTF-8?Q?=E3=82=B9?= + =?UTF-8?Q?=E3=83=88?=