Bug #81349 [NEW]: mb_detect_encoding misdetcts ASCII in some cases
| From: | phofstetter at sensational dot ch | Date: | Wed, 11 Aug 2021 09:24:27 +0000 |
| Subject: | Bug #81349 [NEW]: mb_detect_encoding misdetcts ASCII in some cases | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-235749@lists.php.net to get a copy of this message | ||
From: phofstetter at sensational dot ch
Operating system: macOS
PHP version: 8.1.0beta2
Package: mbstring related
Bug Type: Bug
Bug description:mb_detect_encoding misdetcts ASCII in some cases
Description:
------------
mb_detect_encoding() seems to have changed quite a bit between PHP 8.0
and 8.1 and mostly for the better, TBH.
However, here's a test case where it misdetects a string as being ASCII
when it absolutely cannot be because byte 0 is outside of the 7bit range
of ASCII.
If byte 1 is any non-letter character aside of space, the misdetection
will happen. If it's any letter or space, it's fine.
While in <= PHP 8.0, the function had it's quirks, it would never detect
a string with a character with its high-bit set as ASCII.
Test script:
---------------
<?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");
Expected result:
----------------
ISO-8859-1
ISO-8859-1
Actual result:
--------------
ASCII
ISO-8859-1
--
Edit bug report at https://bugs.php.net/bug.php?id=81349&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81349&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81349&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81349&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81349&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81349&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81349&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81349&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81349&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81349&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81349&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81349&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81349&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81349&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81349&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81349&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81349&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81349&r=mysqlcfg