Skip to content

Commit 50fec3b

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #55146: iconv_mime_decode_headers() skips some headers
2 parents eb03290 + 6922cae commit 50fec3b

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PHP NEWS
1717
(Andrew Nester, Laruence, Anatol)
1818

1919
- iconv:
20+
. Fixed bug #55146 (iconv_mime_decode_headers() skips some headers). (cmb)
2021
. Fixed bug #53891 (iconv_mime_encode() fails to Q-encode UTF-8 string). (cmb)
2122

2223
- libxml:

ext/iconv/iconv.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1545,6 +1545,9 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
15451545

15461546
case 1: /* expecting a delimiter */
15471547
if (*p1 != '?') {
1548+
if (*p1 == '\r' || *p1 == '\n') {
1549+
--p1;
1550+
}
15481551
err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl);
15491552
if (err != PHP_ICONV_ERR_SUCCESS) {
15501553
goto out;

ext/iconv/tests/bug55146.phpt

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
--TEST--
2+
Bug #55146 (iconv_mime_decode_headers() skips some headers)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('iconv')) die('skip iconv extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
10+
$headers = <<< HEADERS
11+
X-Header-One: H4sIAAAAAAAAA+NgFlsCAAA=
12+
X-Header-Two: XtLePq6GTMn8G68F0
13+
HEADERS;
14+
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR));
15+
16+
$headers = <<< HEADERS
17+
X-Header-One: =
18+
X-Header-Two: XtLePq6GTMn8G68F0
19+
HEADERS;
20+
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_STRICT));
21+
?>
22+
===DONE===
23+
--EXPECT--
24+
array(2) {
25+
["X-Header-One"]=>
26+
string(24) "H4sIAAAAAAAAA+NgFlsCAAA="
27+
["X-Header-Two"]=>
28+
string(17) "XtLePq6GTMn8G68F0"
29+
}
30+
array(2) {
31+
["X-Header-One"]=>
32+
string(1) "="
33+
["X-Header-Two"]=>
34+
string(17) "XtLePq6GTMn8G68F0"
35+
}
36+
===DONE===

0 commit comments

Comments
 (0)