Bug #79154 [NEW]: mb_convert_encoding() can modify $from_encoding
| From: | cmb@php.net | Date: | Wed, 22 Jan 2020 09:17:23 +0000 |
| Subject: | Bug #79154 [NEW]: mb_convert_encoding() can modify $from_encoding | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-225042@lists.php.net to get a copy of this message | ||
From: cmb
Operating system: *
PHP version: 7.3Git-2020-01-22 (Git)
Package: mbstring related
Bug Type: Bug
Bug description:mb_convert_encoding() can modify $from_encoding
Description:
------------
If an array containing values which are not strings is passed as
$from_encoding to mb_convert_encoding(), the array is modified
although it is not passed by reference.
This issue is fixed as of PHP 7.4.0.
Test script:
---------------
<?php
class Utf8Encoding
{
public function __toString()
{
return 'UTF-8';
}
}
$utf8encoding = new Utf8Encoding();
$encodings = [$utf8encoding];
var_dump($encodings);
mb_convert_encoding('foo', 'UTF-8', $encodings);
var_dump($encodings);
?>
Expected result:
----------------
array(1) {
[0]=>
object(Utf8Encoding)#1 (0) {
}
}
array(1) {
[0]=>
object(Utf8Encoding)#1 (0) {
}
}
Actual result:
--------------
array(1) {
[0]=>
object(Utf8Encoding)#1 (0) {
}
}
array(1) {
[0]=>
string(5) "UTF-8"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=79154&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=79154&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=79154&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=79154&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=79154&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=79154&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=79154&r=support
Expected behavior: https://bugs.php.net/fix.php?id=79154&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=79154&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=79154&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=79154&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79154&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=79154&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=79154&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=79154&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=79154&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=79154&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=79154&r=mysqlcfg