1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/date/tests/bug-gh9763.phpt
2023-02-08 10:27:33 +00:00

29 lines
1.2 KiB
PHP

--TEST--
Test bug GH-9763: DateTimeZone ctr mishandles input and adds null byte if the argument is an offset larger than 100*60 minutes
--FILE--
<?php
date_default_timezone_set('UTC');
foreach ( [ '+99:60', '+99:62', '-99:62', '-99:60', '+9960', '-9960', '+9959', '-9959' ] as $test )
{
echo "Testing {$test}: ";
try {
$d = new DateTimeZone($test);
echo $d->getName(), "\n";
} catch (Exception $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
?>
--EXPECT--
Testing +99:60: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+99:60)
Testing +99:62: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+99:62)
Testing -99:62: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-99:62)
Testing -99:60: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-99:60)
Testing +9960: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+9960)
Testing -9960: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-9960)
Testing +9959: +99:59
Testing -9959: -99:59