php-src/ext/mbstring/tests/gh9008.phpt
Christoph M. Becker c2bdaa48e1
Fix GH-9008: mb_detect_encoding(): wrong results with null $encodings
Passing `null` to `$encodings` is supposed to behave like passing the
result of `mb_detect_order()`.  Therefore, we need to remove the non-
encodings from the `elist` in this case as well.  Thus, we duplicate
the global `elist`, so we can modify it.

Closes GH-9063.
2022-07-20 16:58:55 +02:00

25 lines
365 B
PHP

--TEST--
GH-9008 (mb_detect_encoding(): wrong results with null $encodings)
--EXTENSIONS--
mbstring
--FILE--
<?php
$string = "<?php
function test()
{
}
";
mb_detect_order(["ASCII", "UUENCODE"]);
var_dump(
mb_detect_encoding($string, null, true),
mb_detect_encoding($string, mb_detect_order(), true),
);
?>
--EXPECT--
string(5) "ASCII"
string(5) "ASCII"