Bug #81665 [NEW]: mb_detect_encoding() should return false

From: Date: Sat, 27 Nov 2021 08:16:05 +0000
Subject: Bug #81665 [NEW]: mb_detect_encoding() should return false
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-238003@lists.php.net to get a copy of this message
From:             alec at alec dot pl
Operating system: 
PHP version:      8.1.0
Package:          mbstring related
Bug Type:         Bug
Bug description:mb_detect_encoding() should return false

Description:
------------
mb_detect_encoding() according to the documentation should return "false
if the string is not valid in any of the listed encodings".

However, the test script shows that this is not the case.

https://3v4l.org/km1R7

Related to bug #48210 which has been closed without proper evaluation,
imo. I hope, my test script is more clear about the issue.

Test script:
---------------
$test = quoted_printable_decode('Piotr Iksi=F1ski');
echo mb_check_encoding($test, 'UTF-8') ? "valid:" : "invalid:";
echo mb_detect_encoding($test, 'ASCII,UTF-8') ?: 'false';

Expected result:
----------------
invalid:false

Actual result:
--------------
invalid:UTF-8

-- 
Edit bug report at https://bugs.php.net/bug.php?id=81665&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=81665&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=81665&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=81665&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=81665&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=81665&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=81665&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=81665&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=81665&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=81665&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=81665&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81665&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=81665&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=81665&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=81665&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=81665&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=81665&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=81665&r=mysqlcfg


Thread (3 messages)

« previous php.bugs (#238003) next »