Skip to content

Commit 355a4b5

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
2 parents 6a20ef9 + 0056d01 commit 355a4b5

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ PHP NEWS
1616
- LDAP:
1717
. Fix memory leak in ldap_set_options(). (ndossche)
1818

19+
- Mbstring
20+
. Fixed bug GH-20674 (Fix GH-20674 mb_decode_mimeheader does not handle
21+
separator). (Yuya Hamada)
22+
1923
- SPL:
2024
. Fixed bug GH-20678 (resource created by GlobIterator crashes with fclose()).
2125
(David Carlier)

ext/mbstring/mbstring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6662,13 +6662,15 @@ static zend_string* mb_mime_header_decode(zend_string *input, const mbfl_encodin
66626662
p = temp;
66636663
/* Decoding of MIME encoded word was successful;
66646664
* Try to collapse a run of whitespace */
6665-
if (p < e && (*p == '\n' || *p == '\r')) {
6665+
if (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' ')) {
66666666
do {
66676667
p++;
66686668
} while (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' '));
66696669
/* We will only actually output a space if this is not immediately followed
66706670
* by another valid encoded word */
66716671
space_pending = true;
6672+
} else {
6673+
space_pending = false;
66726674
}
66736675
continue;
66746676
}

ext/mbstring/tests/gh20674.phpt

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
--TEST--
2+
GH-20674 (mb_decode_mimeheader does not handle separator)
3+
--EXTENSIONS--
4+
mbstring
5+
--FILE--
6+
<?php
7+
8+
$subject = '=?us-ascii?Q?The_PH?= =?us-ascii?Q?P_8.5?=';
9+
var_dump(mb_decode_mimeheader($subject));
10+
11+
// mb_decode_mimeheader's backward compatible for TAB(\t)
12+
$subject = "=?us-ascii?Q?The_PH?=\t=?us-ascii?Q?P_8.5?=";
13+
var_dump(mb_decode_mimeheader($subject));
14+
15+
$subject = "=?us-ascii?Q?The_PH?=\t =?us-ascii?Q?P_8.5?=";
16+
var_dump(mb_decode_mimeheader($subject));
17+
18+
$subject = "=?us-ascii?Q?The_PH?= \t =?us-ascii?Q?P_8.5?=";
19+
var_dump(mb_decode_mimeheader($subject));
20+
21+
// from RFC 2047 https://www.ietf.org/rfc/rfc2047#section-8
22+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?=)"));
23+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= b)"));
24+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a_b?=)"));
25+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)"));
26+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)"));
27+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?=
28+
=?ISO-8859-1?Q?b?=)"));
29+
?>
30+
--EXPECTF--
31+
string(11) "The PHP 8.5"
32+
string(11) "The PHP 8.5"
33+
string(11) "The PHP 8.5"
34+
string(11) "The PHP 8.5"
35+
string(3) "(a)"
36+
string(5) "(a b)"
37+
string(5) "(a b)"
38+
string(4) "(ab)"
39+
string(4) "(ab)"
40+
string(4) "(ab)"

0 commit comments

Comments
 (0)