1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 08:12:21 +01:00
Files
archived-php-src/ext/intl/tests/msgfmt_format_error4.phpt
Niels Dossche b81f770d39 Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4:
  intl: Fix leak in umsg_format_helper()
2025-12-22 12:18:14 +01:00

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)