Merge branch 'PHP-7.2' into PHP-7.3

* PHP-7.2:
  Fix #55146: iconv_mime_decode_headers() skips some headers
This commit is contained in:
Christoph M. Becker 2018-08-25 14:42:35 +02:00
commit 50fec3be0e
3 changed files with 40 additions and 0 deletions

1
NEWS
View File

@ -17,6 +17,7 @@ PHP NEWS
(Andrew Nester, Laruence, Anatol)
- iconv:
. Fixed bug #55146 (iconv_mime_decode_headers() skips some headers). (cmb)
. Fixed bug #53891 (iconv_mime_encode() fails to Q-encode UTF-8 string). (cmb)
- libxml:

View File

@ -1545,6 +1545,9 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
case 1: /* expecting a delimiter */
if (*p1 != '?') {
if (*p1 == '\r' || *p1 == '\n') {
--p1;
}
err = _php_iconv_appendl(pretval, encoded_word, (size_t)((p1 + 1) - encoded_word), cd_pl);
if (err != PHP_ICONV_ERR_SUCCESS) {
goto out;

View File

@ -0,0 +1,36 @@
--TEST--
Bug #55146 (iconv_mime_decode_headers() skips some headers)
--SKIPIF--
<?php
if (!extension_loaded('iconv')) die('skip iconv extension not available');
?>
--FILE--
<?php
$headers = <<< HEADERS
X-Header-One: H4sIAAAAAAAAA+NgFlsCAAA=
X-Header-Two: XtLePq6GTMn8G68F0
HEADERS;
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_CONTINUE_ON_ERROR));
$headers = <<< HEADERS
X-Header-One: =
X-Header-Two: XtLePq6GTMn8G68F0
HEADERS;
var_dump(iconv_mime_decode_headers($headers, ICONV_MIME_DECODE_STRICT));
?>
===DONE===
--EXPECT--
array(2) {
["X-Header-One"]=>
string(24) "H4sIAAAAAAAAA+NgFlsCAAA="
["X-Header-Two"]=>
string(17) "XtLePq6GTMn8G68F0"
}
array(2) {
["X-Header-One"]=>
string(1) "="
["X-Header-Two"]=>
string(17) "XtLePq6GTMn8G68F0"
}
===DONE===