Skip to content

Commit a56cdd0

Browse files
committed
Fix #77147: Fix for 60494 ignores ICONV_MIME_DECODE_CONTINUE_ON_ERROR
If the `ICONV_MIME_DECODE_CONTINUE_ON_ERROR` flag is set, parsing should not fail, if there are illegal characters in the headers; instead we silently ignore these like before.
1 parent ec2e7a2 commit a56cdd0

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? 2018, PHP 7.1.25
44

5+
- iconv:
6+
. Fixed bug #77147 (Fixing 60494 ignored ICONV_MIME_DECODE_CONTINUE_ON_ERROR).
7+
(cmb)
8+
59
- ODBC:
610
. Fixed bug #77079 (odbc_fetch_object has incorrect type signature).
711
(Jon Allen)

ext/iconv/iconv.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1546,7 +1546,11 @@ static php_iconv_err_t _php_iconv_mime_decode(smart_str *pretval, const char *st
15461546
default: /* first letter of a non-encoded word */
15471547
err = _php_iconv_appendc(pretval, *p1, cd_pl);
15481548
if (err != PHP_ICONV_ERR_SUCCESS) {
1549-
goto out;
1549+
if (mode & PHP_ICONV_MIME_DECODE_CONTINUE_ON_ERROR) {
1550+
err = PHP_ICONV_ERR_SUCCESS;
1551+
} else {
1552+
goto out;
1553+
}
15501554
}
15511555
encoded_word = NULL;
15521556
if ((mode & PHP_ICONV_MIME_DECODE_STRICT)) {

ext/iconv/tests/bug77147.phpt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
--TEST--
2+
Bug #77147 (Fixing 60494 ignored ICONV_MIME_DECODE_CONTINUE_ON_ERROR)
3+
--SKIPIF--
4+
<?php
5+
if (!extension_loaded('iconv')) die('skip iconv extension not available');
6+
?>
7+
--FILE--
8+
<?php
9+
$string = <<<EOF
10+
Feedback-ID: 014a93e3-1f5e-4df6-b347-6b59f0f746b8:b5891053-55d1-45bc-a0b5-47a7a9b59687:email:epslh1�
11+
EOF;
12+
$headers = iconv_mime_decode_headers($string, ICONV_MIME_DECODE_CONTINUE_ON_ERROR);
13+
var_dump($headers);
14+
?>
15+
===DONE===
16+
--EXPECT--
17+
array(1) {
18+
["Feedback-ID"]=>
19+
string(86) "014a93e3-1f5e-4df6-b347-6b59f0f746b8:b5891053-55d1-45bc-a0b5-47a7a9b59687:email:epslh1"
20+
}
21+
===DONE===

0 commit comments

Comments
 (0)