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
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: cmb@php.net
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Apr 16 14:01:29 2024 UTC