xref: /PHP-8.3/ext/intl/tests/bug62017.phpt (revision 74859783)
1--TEST--
2Bug #62017: datefmt_create with incorrectly encoded timezone leaks pattern
3--EXTENSIONS--
4intl
5--FILE--
6<?php
7ini_set('intl.error_level', E_WARNING);
8var_dump(
9    datefmt_create('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "\xFF",
10        IntlDateFormatter::GREGORIAN, 'a'));
11try {
12    var_dump(
13        new IntlDateFormatter('', IntlDateFormatter::NONE, IntlDateFormatter::NONE, "Europe/Lisbon",
14            IntlDateFormatter::GREGORIAN, "\x80"));
15} catch (IntlException $e) {
16    echo PHP_EOL."Exception: " . $e->getMessage() . " in " . $e->getFile() . " on line " . $e->getLine() . PHP_EOL;
17}
18?>
19--EXPECTF--
20Warning: datefmt_create(): datefmt_create: Time zone identifier given is not a valid UTF-8 string in %s on line %d
21NULL
22
23Exception: IntlDateFormatter::__construct(): datefmt_create: error converting pattern to UTF-16 in %sbug62017.php on line %d
24