summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph M. Becker <cmbecker69@gmx.de>2018-08-26 13:20:22 +0200
committerChristoph M. Becker <cmbecker69@gmx.de>2018-08-26 13:21:22 +0200
commit20849b0b0fa60e257a75a3182dff5095811c80d8 (patch)
treef3ca0e7ae8c8621e27969a9c9e8e0aa3f90dd865
parent314b8ecf8b07a8b87efeca5454e36a6b55ca4dd1 (diff)
parentefb86aef12ff4f8f3908ceff2844f7511f7d61eb (diff)
downloadphp-git-20849b0b0fa60e257a75a3182dff5095811c80d8.tar.gz
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: Fix #68180: iconv_mime_decode can return extra characters in a header
-rw-r--r--NEWS2
-rw-r--r--ext/iconv/iconv.c4
-rw-r--r--ext/iconv/tests/bug68180.phpt16
3 files changed, 20 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index ed18c166f0..81fe98aaee 100644
--- a/NEWS
+++ b/NEWS
@@ -16,6 +16,8 @@ PHP NEWS
. Fixed bug #76517 (incorrect restoring of LDFLAGS). (sji)
- iconv:
+ . Fixed bug #68180 (iconv_mime_decode can return extra characters in a
+ header). (cmb)
. Fixed bug #63839 (iconv_mime_decode_headers function is skipping headers).
(cmb)
. Fixed bug #60494 (iconv_mime_decode does ignore special characters). (cmb)
diff --git a/ext/iconv/iconv.c b/ext/iconv/iconv.c
index 6e3202e6fa..9a3c2d02fd 100644
--- a/ext/iconv/iconv.c
+++ b/ext/iconv/iconv.c
@@ -462,7 +462,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l,
if (in_p != NULL) {
while (in_left > 0) {
- out_left = buf_growth - out_left;
+ out_left = buf_growth;
smart_str_alloc(d, out_left, 0);
out_p = ZSTR_VAL((d)->s) + ZSTR_LEN((d)->s);
@@ -496,7 +496,7 @@ static php_iconv_err_t _php_iconv_appendl(smart_str *d, const char *s, size_t l,
}
} else {
for (;;) {
- out_left = buf_growth - out_left;
+ out_left = buf_growth;
smart_str_alloc(d, out_left, 0);
out_p = ZSTR_VAL((d)->s) + ZSTR_LEN((d)->s);
diff --git a/ext/iconv/tests/bug68180.phpt b/ext/iconv/tests/bug68180.phpt
new file mode 100644
index 0000000000..3442629235
--- /dev/null
+++ b/ext/iconv/tests/bug68180.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Bug #68180 (iconv_mime_decode can return extra characters in a header)
+--SKIPIF--
+<?php
+if (!extension_loaded('iconv')) die('skip iconv extension not available');
+?>
+--FILE--
+<?php
+$original = "=?UTF-8?Q?=E3=80=8E=E3=80=90=E5=A4=96=E8=B3=87=E7=B3=BB=E6=88=A6=E7=95=A5=E3=82=B3=E3=83=B3=E3=82=B5=E3=83=AB=E3=81=8C=E9=9B=86=E7=B5=90=E3=80=91=E3=83=88=E3=83=83=E3=83=97=E3=82=B3=E3=83=B3=E3=82=B5=E3=83=AB=E3=82=BF=E3=83=B3=E3=83=88=E3=81=A8=E8=A9=B1=E3=81=9B=E3=82=8B=E3=82=B3=E3=83=B3=E3=82=B5=E3=83=AB=E6=A5=AD=E7=95=8C=E7=A0=94=E7=A9=B6=E3=82=BB=E3=83=9F=E3=83=8A=E3=83=BC=E3=80=8F=E3=81=B8=E3=81=AE=E3=82=A8=E3=83=B3=E3=83=88=E3=83=AA=E3=83=BC=E3=81=82=E3=82=8A=E3=81=8C=E3=81=A8=E3=81=86=E3=81=94=E3=81=96=E3=81=84=E3=81=BE=E3=81=97=E3=81=9F=E3=80=82?=";
+$decoded = iconv_mime_decode($original, ICONV_MIME_DECODE_STRICT, 'utf-8');
+var_dump($decoded);
+?>
+===DONE===
+--EXPECT--
+string(183) "『【外資系戦略コンサルが集結】トップコンサルタントと話せるコンサル業界研究セミナー』へのエントリーありがとうございました。"
+===DONE===