php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #81665 mb_detect_encoding() should return false
Submitted: 2021-11-27 08:16 UTC Modified: 2021-11-27 08:19 UTC
From: alec at alec dot pl Assigned:
Status: Closed Package: mbstring related
PHP Version: 8.1.0 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alec at alec dot pl
New email:
PHP Version: OS:

 

 [2021-11-27 08:16 UTC] alec at alec dot pl
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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2021-11-27 08:19 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2021-11-27 08:19 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

https://www.php.net/manual/en/function.mb-detect-encoding.php
> strict
> Controls the behaviour when string is not valid in any of the listed encodings.
> If strict is set to false, the closest matching encoding will be returned; if
> strict is set to true, false will be returned.

https://3v4l.org/TUqZ1
 [2021-11-27 08:19 UTC] alec at alec dot pl
-Status: Not a bug +Status: Closed
 [2021-11-27 08:19 UTC] alec at alec dot pl
Oops, looks like I missed the meaning of the 3rd argument.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Jan 24 04:03:41 2022 UTC