php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79154 mb_convert_encoding() can modify $from_encoding
Submitted: 2020-01-22 09:17 UTC Modified: 2020-01-22 09:17 UTC
From: cmb@php.net Assigned: cmb (profile)
Status: Closed Package: mbstring related
PHP Version: 7.3Git-2020-01-22 (Git) OS: *
Private report: No CVE-ID: None
 [2020-01-22 09:17 UTC] cmb@php.net
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"
}


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-01-22 09:17 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-01-22 09:33 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=9be31a582a83c38cdace9d54778398bc9fe0c7a9
Log: Fix #79154: mb_convert_encoding() can modify $from_encoding
 [2020-01-22 09:33 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 28 09:01:28 2024 UTC