Skip to content

Commit 1e8b747

Browse files
committed
Add test case from RFC2047 and fix last pattern
See: https://www.ietf.org/rfc/rfc2047#section-8 And fix (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=) as (a b).
1 parent c2e0d8d commit 1e8b747

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

ext/mbstring/mbstring.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6402,6 +6402,8 @@ static zend_string* mb_mime_header_decode(zend_string *input, const mbfl_encodin
64026402
/* We will only actually output a space if this is not immediately followed
64036403
* by another valid encoded word */
64046404
space_pending = true;
6405+
} else {
6406+
space_pending = false;
64056407
}
64066408
continue;
64076409
}

ext/mbstring/tests/gh20674.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,24 @@ var_dump(mb_decode_mimeheader($subject));
1717

1818
$subject = "=?us-ascii?Q?The_PH?= \t =?us-ascii?Q?P_8.5?=";
1919
var_dump(mb_decode_mimeheader($subject));
20+
21+
// from RFC 2047 https://www.ietf.org/rfc/rfc2047
22+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)"));
23+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a_b?=)"));
24+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)"));
25+
var_dump(mb_decode_mimeheader("(=?ISO-8859-1?Q?a?= 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?=)"));
2029
?>
2130
--EXPECTF--
2231
string(11) "The PHP 8.5"
2332
string(11) "The PHP 8.5"
2433
string(11) "The PHP 8.5"
2534
string(11) "The PHP 8.5"
35+
string(5) "(a b)"
36+
string(5) "(a b)"
37+
string(4) "(ab)"
38+
string(5) "(a b)"
39+
string(4) "(ab)"
40+
string(4) "(ab)"

0 commit comments

Comments
 (0)