Skip to content

Commit 64dd933

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
2 parents 3a49327 + 355a4b5 commit 64dd933

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
@@ -17,6 +17,10 @@ PHP NEWS
1717
. Fixed bug GH-20668 (\Uri\WhatWg\Url::withHost() crashes (SEGV) for URLs
1818
using the file: scheme). (lexborisov)
1919

20+
- Mbstring
21+
. Fixed bug GH-20674 (Fix GH-20674 mb_decode_mimeheader does not handle
22+
separator). (Yuya Hamada)
23+
2024
- Sqlite3:
2125
. Fixed bug GH-20699 (SQLite3Result fetchArray return array|false,
2226
null returned). (ndossche, plusminmax)

ext/mbstring/mbstring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6667,13 +6667,15 @@ static zend_string* mb_mime_header_decode(zend_string *input, const mbfl_encodin
66676667
p = temp;
66686668
/* Decoding of MIME encoded word was successful;
66696669
* Try to collapse a run of whitespace */
6670-
if (p < e && (*p == '\n' || *p == '\r')) {
6670+
if (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' ')) {
66716671
do {
66726672
p++;
66736673
} while (p < e && (*p == '\n' || *p == '\r' || *p == '\t' || *p == ' '));
66746674
/* We will only actually output a space if this is not immediately followed
66756675
* by another valid encoded word */
66766676
space_pending = true;
6677+
} else {
6678+
space_pending = false;
66776679
}
66786680
continue;
66796681
}

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)