Bug #76708 [NEW]: mb_detect_encoding behaves inconsistenly depending on the argument type
| From: | smokey101stair at gmail dot com | Date: | Sun, 05 Aug 2018 05:51:42 +0000 |
| Subject: | Bug #76708 [NEW]: mb_detect_encoding behaves inconsistenly depending on the argument type | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-216600@lists.php.net to get a copy of this message | ||
From: smokey101stair at gmail dot com
Operating system: Irrelevant
PHP version: Irrelevant
Package: mbstring related
Bug Type: Bug
Bug description:mb_detect_encoding behaves inconsistenly depending on the argument type
Description:
------------
Similar to Bug 76704. mb_detect_encoding()'s second parameter,
$encoding_list, takes either an array of encodings or a comma separated
string of encodings. However, its behavior varies depending on whether
an array or string is passed to $encoding_list, when that value contains
both a supported and unsupported encoding.
Test script:
---------------
https://3v4l.org/KTBkK
Expected result:
----------------
Honestly.. I'm not entirely sure.
Setting mb_detect_encodings()'s second parameter is really doing the
same thing as if you had passed the same thing to mb_detect_order(),
which returns false (now that Bug 76704 is fixed) if any of the given
encodings are not supported.
Option 1) In the interest of consistency, this should probably also
return false if any of the given encodings are not supported. Doing this
would probably be a a BC break, and I don't know how popular this
function really is.
Option 2) Match what is currently done when an array is given and emit a
warning and silently fallback to the value of mb_detect_order().
Option 3) Match what is currently done when a string is given and
silently try to match against any of the supported encodings.
Actual result:
--------------
If $encoding_list is a string, and tries to match the given string
against the supported encoding. No warning is emitted.
If $encoding_list is an array, then a warning is emitted and it tries to
match the given string against the fallback value of mb_detect_order().
--
Edit bug report at https://bugs.php.net/bug.php?id=76708&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76708&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76708&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76708&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76708&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76708&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76708&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76708&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76708&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76708&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76708&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76708&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76708&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76708&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76708&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76708&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76708&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76708&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76708&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76708&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76708&r=mysqlcfg