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