Skip to content

Commit

Permalink
Fixed bug #81349
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nikic committed Aug 11, 2021
1 parent 923ff9f commit 28500fe
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ PHP NEWS
. Fixed bug #81106 (Regression in 8.1: add() now truncate ->f). (Derick)
. Fixed bug #81273 (Date interval calculation not correct). (Derick)

- Mbstring:
. Fixed bug #81349 (mb_detect_encoding misdetcts ASCII in some cases).
(Nikita)

05 Aug 2021, PHP 8.1.0beta2

Expand Down
2 changes: 1 addition & 1 deletion ext/mbstring/libmbfl/filters/mbfilter_singlebyte.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static int mbfl_filt_conv_ascii_wchar(int c, mbfl_convert_filter *filter)
if (c < 0x80) {
CK((*filter->output_function)(c, filter->data));
} else {
CK(mbfl_filt_conv_illegal_output(c, filter));
CK((*filter->output_function)(c | MBFL_WCSGROUP_THROUGH, filter->data));
}
return c;
}
Expand Down
12 changes: 12 additions & 0 deletions ext/mbstring/tests/bug81349.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
Bug #81349: mb_detect_encoding misdetcts ASCII in some cases
--FILE--
<?php

echo(mb_detect_encoding("\xe4,a", ['ASCII', 'UTF-8', 'ISO-8859-1'])."\n");
echo(mb_detect_encoding("\xe4 a", ['ASCII', 'UTF-8', 'ISO-8859-1'])."\n");

?>
--EXPECT--
ISO-8859-1
ISO-8859-1

2 comments on commit 28500fe

@Girgias
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Window's build seems to be failing with this new test.

@nikic
Copy link
Member Author

@nikic nikic commented on 28500fe Aug 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fixed by 1417318.

Please sign in to comment.