Skip to content

Commit 49466af

Browse files
committed
Merge branch 'PHP-8.0' into PHP-8.1
* PHP-8.0: Fix GH-7980: Unexpected result for iconv_mime_decode
2 parents 188a6cc + 86c196b commit 49466af

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ PHP NEWS
77

88
- Iconv:
99
. Fixed bug GH-7953 (ob_clean() only does not set Content-Encoding). (cmb)
10+
. Fixed bug GH-7980 (Unexpected result for iconv_mime_decode). (cmb)
1011

1112
- Zlib:
1213
. Fixed bug GH-7953 (ob_clean() only does not set Content-Encoding). (cmb)

ext/iconv/iconv.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,9 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
15781578
}
15791579

15801580
err = _php_iconv_appendl(pretval, ZSTR_VAL(decoded_text), ZSTR_LEN(decoded_text), cd);
1581+
if (err == PHP_ICONV_ERR_SUCCESS) {
1582+
err = _php_iconv_appendl(pretval, NULL, 0, cd);
1583+
}
15811584
zend_string_release_ex(decoded_text, 0);
15821585

15831586
if (err != PHP_ICONV_ERR_SUCCESS) {
@@ -1718,13 +1721,6 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
17181721
*next_pos = p1;
17191722
}
17201723

1721-
if (cd != (iconv_t)(-1)) {
1722-
_php_iconv_appendl(pretval, NULL, 0, cd);
1723-
}
1724-
if (cd_pl != (iconv_t)(-1)) {
1725-
_php_iconv_appendl(pretval, NULL, 0, cd_pl);
1726-
}
1727-
17281724
smart_str_0(pretval);
17291725
out:
17301726
if (cd != (iconv_t)(-1)) {

ext/iconv/tests/gh7980.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug GH-7980 (Unexpected result for iconv_mime_decode)
3+
--EXTENSIONS--
4+
iconv
5+
--FILE--
6+
<?php
7+
$subject = '=?windows-1258?Q?DSI_Charg=E9_de_Formation_Jean_Dupont?= <[email protected]>';
8+
var_dump(iconv_mime_decode($subject, ICONV_MIME_DECODE_STRICT, 'UTF-8'));
9+
?>
10+
--EXPECT--
11+
string(57) "DSI Chargé de Formation Jean Dupont <[email protected]>"

0 commit comments

Comments
 (0)