Skip to content

Commit ff76694

Browse files
committed
Merge branch 'PHP-8.1'
* PHP-8.1: mb_check_encoding($str, '7bit') rejects strings with bytes over 0x7F
2 parents 3be34c3 + 8a8533d commit ff76694

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

ext/mbstring/libmbfl/filters/mbfilter_7bit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const struct mbfl_convert_vtbl vtbl_7bit_8bit = {
6969

7070
int mbfl_filt_conv_7bit_any(int c, mbfl_convert_filter *filter)
7171
{
72-
return (*filter->output_function)(c, filter->data);
72+
return (*filter->output_function)(c < 0x80 ? c : MBFL_BAD_INPUT, filter->data);
7373
}
7474

7575

ext/mbstring/tests/other_encodings.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ mb_substitute_character(0x25);
1414
var_dump(mb_convert_encoding("ABC", "7bit", "ASCII"));
1515
var_dump(mb_convert_encoding("\x80", "7bit", "ASCII"));
1616
var_dump(mb_convert_encoding("ABC", "8bit", "7bit"));
17+
var_dump(mb_check_encoding(chr(255), '7bit'));
1718
echo "7bit done\n";
1819

1920
// "8bit"
20-
var_dump(mb_convert_encoding("\x01\x00", "8bit", "UTF-16BE")); // codepoints over 0xFF are illegal or '8-bit'
21+
var_dump(mb_convert_encoding("\x01\x00", "8bit", "UTF-16BE")); // codepoints over 0xFF are illegal for '8-bit'
2122
echo "8bit done\n";
2223

2324
?>
2425
--EXPECT--
2526
string(3) "ABC"
2627
string(1) "%"
2728
string(3) "ABC"
29+
bool(false)
2830
7bit done
2931
string(1) "%"
3032
8bit done

0 commit comments

Comments
 (0)