xref: /php-src/ext/date/tests/bug-gh9763.phpt (revision b7860cd5)
1--TEST--
2Test bug GH-9763: DateTimeZone ctr mishandles input and adds null byte if the argument is an offset larger than 100*60 minutes
3--FILE--
4<?php
5date_default_timezone_set('UTC');
6
7foreach ( [ '+99:60', '+99:62', '-99:62', '-99:60', '+9960', '-9960', '+9959', '-9959' ] as $test )
8{
9	echo "Testing {$test}: ";
10	try {
11		$d = new DateTimeZone($test);
12		echo $d->getName(), "\n";
13	} catch (Exception $e) {
14		echo $e::class, ': ', $e->getMessage(), "\n";
15	}
16}
17
18
19?>
20--EXPECT--
21Testing +99:60: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+99:60)
22Testing +99:62: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+99:62)
23Testing -99:62: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-99:62)
24Testing -99:60: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-99:60)
25Testing +9960: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (+9960)
26Testing -9960: DateInvalidTimeZoneException: DateTimeZone::__construct(): Timezone offset is out of range (-9960)
27Testing +9959: +99:59
28Testing -9959: -99:59
29