Bug #81312 [NEW]: mb_convert_variables() corrupts reference of array element
| From: | heguangyu5 at qq dot com | Date: | Fri, 30 Jul 2021 03:18:38 +0000 |
| Subject: | Bug #81312 [NEW]: mb_convert_variables() corrupts reference of array element | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-235467@lists.php.net to get a copy of this message | ||
From: heguangyu5 at qq dot com
Operating system: ubuntu
PHP version: 7.4.22
Package: mbstring related
Bug Type: Bug
Bug description:mb_convert_variables() corrupts reference of array element
Description:
------------
mb_convert_variables() should only convert enconding of array elements
but not change the array structure.
Test script:
---------------
<?php
$a = " ¢Ââ¬ÂÅ ÂÅ¡";
$b = array(&$a);
$c = $b;
var_dump($a, $b, $c);
$c[0] .= " abc";
var_dump($a, $b, $c);
mb_convert_variables("EUC-JP", "Shift_JIS", $c);
var_dump($a, $b, $c);
$c[0] .= " def";
var_dump($a, $b, $c);
Expected result:
----------------
string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
array(1) {
[0]=>
&string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
}
array(1) {
[0]=>
&string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
}
string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
string(15) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc"
array(1) {
[0]=>
&string(15) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc"
}
array(1) {
[0]=>
&string(15) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc"
}
string(20) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc def"
array(1) {
[0]=>
&string(20) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc def"
}
array(1) {
[0]=>
&string(20) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc def"
}
Actual result:
--------------
string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
array(1) {
[0]=>
&string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
}
array(1) {
[0]=>
&string(10) " ¢Ââ¬ÂÅ ÂÅ¡"
}
string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
array(1) {
[0]=>
string(15) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc"
}
string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
array(1) {
[0]=>
&string(15) " ¢Ââ¬ÂÅ ÂÅ¡ abc"
}
array(1) {
[0]=>
string(20) "â¬Â¢â¬â¬â¬Å â¬Å¡â¬Âª abc def"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=81312&edit=1
--
Fix committed: https://bugs.php.net/fix.php?id=81312&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=81312&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=81312&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=81312&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=81312&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=81312&r=support
Expected behavior: https://bugs.php.net/fix.php?id=81312&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=81312&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=81312&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=81312&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=81312&r=phptooold
Daylight Savings: https://bugs.php.net/fix.php?id=81312&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=81312&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=81312&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=81312&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=81312&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=81312&r=mysqlcfg