Skip to content

Commit 065eee1

Browse files
committed
Merge branch 'PHP-7.2' into PHP-7.3
* PHP-7.2: Fix #63839: iconv_mime_decode_headers function is skipping headers
2 parents 50fec3b + 7e176dd commit 065eee1

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

NEWS

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

1919
- iconv:
20+
. Fixed bug #63839 (iconv_mime_decode_headers function is skipping headers).
21+
(cmb)
2022
. Fixed bug #55146 (iconv_mime_decode_headers() skips some headers). (cmb)
2123
. Fixed bug #53891 (iconv_mime_encode() fails to Q-encode UTF-8 string). (cmb)
2224

ext/iconv/iconv.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,6 +1573,23 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
15731573
case '*': /* new style delimiter: locale id follows */
15741574
scan_stat = 10;
15751575
break;
1576+
1577+
case '\r': case '\n': /* not an encoded-word */
1578+
--p1;
1579+
_php_iconv_appendc(pretval, '=', cd_pl);
1580+
_php_iconv_appendc(pretval, '?', cd_pl);
1581+
err = _php_iconv_appendl(pretval, csname, (size_t)((p1 + 1) - csname), cd_pl);
1582+
if (err != PHP_ICONV_ERR_SUCCESS) {
1583+
goto out;
1584+
}
1585+
csname = NULL;
1586+
if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {
1587+
scan_stat = 12;
1588+
}
1589+
else {
1590+
scan_stat = 0;
1591+
}
1592+
continue;
15761593
}
15771594
if (scan_stat != 2) {
15781595
char tmpbuf[80];

ext/iconv/tests/bug63839.phpt

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
--TEST--
2+
Bug #63839 (iconv_mime_decode_headers function is skipping headers)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('iconv')) die('skip iconv extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$headers = 'From: "xyz" <xyz@xyz.com>
10+
To: <xyz@xyz.com>
11+
Subject: Reply Is? white side-LED =? in Help
12+
Date: Sat, 22 Dec 2012
13+
Message-ID: <006f01cde00e$d9f79da0$8de6d8e0>
14+
MIME-Version: 1.0
15+
Content-Type: multipart/alternative;
16+
boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0"
17+
X-Mailer: Microsoft Office Outlook 12.0
18+
Thread-Index: Ac3gDtcH2huHjzYcQVmFJPPoWjJogA==
19+
Content-Language: en-us
20+
21+
';
22+
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR));
23+
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_STRICT));
24+
?>
25+
===DONE===
26+
--EXPECT--
27+
array(10) {
28+
["From"]=>
29+
string(19) ""xyz" <xyz@xyz.com>"
30+
["To"]=>
31+
string(13) "<xyz@xyz.com>"
32+
["Subject"]=>
33+
string(35) "Reply Is? white side-LED =? in Help"
34+
["Date"]=>
35+
string(16) "Sat, 22 Dec 2012"
36+
["Message-ID"]=>
37+
string(32) "<006f01cde00e$d9f79da0$8de6d8e0>"
38+
["MIME-Version"]=>
39+
string(3) "1.0"
40+
["Content-Type"]=>
41+
string(75) "multipart/alternative; boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0""
42+
["X-Mailer"]=>
43+
string(29) "Microsoft Office Outlook 12.0"
44+
["Thread-Index"]=>
45+
string(32) "Ac3gDtcH2huHjzYcQVmFJPPoWjJogA=="
46+
["Content-Language"]=>
47+
string(5) "en-us"
48+
}
49+
array(10) {
50+
["From"]=>
51+
string(19) ""xyz" <xyz@xyz.com>"
52+
["To"]=>
53+
string(13) "<xyz@xyz.com>"
54+
["Subject"]=>
55+
string(35) "Reply Is? white side-LED =? in Help"
56+
["Date"]=>
57+
string(16) "Sat, 22 Dec 2012"
58+
["Message-ID"]=>
59+
string(32) "<006f01cde00e$d9f79da0$8de6d8e0>"
60+
["MIME-Version"]=>
61+
string(3) "1.0"
62+
["Content-Type"]=>
63+
string(75) "multipart/alternative; boundary="----=_NextPart_000_0070_01CDE03C.F3AFD9A0""
64+
["X-Mailer"]=>
65+
string(29) "Microsoft Office Outlook 12.0"
66+
["Thread-Index"]=>
67+
string(32) "Ac3gDtcH2huHjzYcQVmFJPPoWjJogA=="
68+
["Content-Language"]=>
69+
string(5) "en-us"
70+
}
71+
===DONE===

0 commit comments

Comments
 (0)