Skip to content

Commit 28500fe

Browse files
committed
Fixed bug #81349
The ascii to wchar was reporting errors using conv_illegal_output, while it should have been using WCSGROUP_THROUGH. Effectively that replaced illegal characters with '?' for the purpose of identification.
1 parent 923ff9f commit 28500fe

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ PHP NEWS
1919
. Fixed bug #81106 (Regression in 8.1: add() now truncate ->f). (Derick)
2020
. Fixed bug #81273 (Date interval calculation not correct). (Derick)
2121

22+
- Mbstring:
23+
. Fixed bug #81349 (mb_detect_encoding misdetcts ASCII in some cases).
24+
(Nikita)
2225

2326
05 Aug 2021, PHP 8.1.0beta2
2427

ext/mbstring/libmbfl/filters/mbfilter_singlebyte.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ static int mbfl_filt_conv_ascii_wchar(int c, mbfl_convert_filter *filter)
9999
if (c < 0x80) {
100100
CK((*filter->output_function)(c, filter->data));
101101
} else {
102-
CK(mbfl_filt_conv_illegal_output(c, filter));
102+
CK((*filter->output_function)(c | MBFL_WCSGROUP_THROUGH, filter->data));
103103
}
104104
return c;
105105
}

ext/mbstring/tests/bug81349.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #81349: mb_detect_encoding misdetcts ASCII in some cases
3+
--FILE--
4+
<?php
5+
6+
echo(mb_detect_encoding("\xe4,a", ['ASCII', 'UTF-8', 'ISO-8859-1'])."\n");
7+
echo(mb_detect_encoding("\xe4 a", ['ASCII', 'UTF-8', 'ISO-8859-1'])."\n");
8+
9+
?>
10+
--EXPECT--
11+
ISO-8859-1
12+
ISO-8859-1

0 commit comments

Comments
 (0)