mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
--TEST--
|
|
MessageFormatter::format() invalid UTF-8 for arg key or value
|
|
--EXTENSIONS--
|
|
intl
|
|
--INI--
|
|
intl.use_exceptions=On
|
|
--FILE--
|
|
<?php
|
|
|
|
$fmt = <<<EOD
|
|
{foo}
|
|
EOD;
|
|
|
|
$mf = new MessageFormatter('en_US', $fmt);
|
|
try {
|
|
var_dump($mf->format(array("foo" => 7, "\x80" => "bar")));
|
|
} catch (Throwable $e) {
|
|
var_dump($e::class === 'IntlException');
|
|
var_dump("MessageFormatter::format(): Invalid UTF-8 data in argument key: '\x80'" === $e->getMessage());
|
|
}
|
|
|
|
try {
|
|
var_dump($mf->format(array("foo" => "\x80")));
|
|
} catch (Throwable $e) {
|
|
var_dump($e::class === 'IntlException');
|
|
var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
|
|
}
|
|
|
|
try {
|
|
var_dump($mf->format(array("foo" => new class {
|
|
function __toString(): string {
|
|
return str_repeat("\x80", random_int(1, 1));
|
|
}
|
|
})));
|
|
} catch (Throwable $e) {
|
|
var_dump($e::class === 'IntlException');
|
|
var_dump("MessageFormatter::format(): Invalid UTF-8 data in string argument: '\x80'" === $e->getMessage());
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|
|
bool(true)
|