summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--NEWS2
-rw-r--r--ext/iconv/iconv.c2
-rw-r--r--ext/iconv/tests/bug48289.phpt22
3 files changed, 25 insertions, 1 deletions
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--
+<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
+--FILE--
+<?php
+$text = "\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88\xE3\x83\x86\xE3\x82\xB9\xE3\x83\x88";
+$options = array(
+ 'scheme' => '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?=