Bug #78139 [NEW]: timezone_open accepts invalid timezone string argument
| From: | baby-luck at earthling dot net | Date: | Tue, 11 Jun 2019 06:30:14 +0000 |
| Subject: | Bug #78139 [NEW]: timezone_open accepts invalid timezone string argument | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-221209@lists.php.net to get a copy of this message | ||
From: baby-luck at earthling dot net
Operating system: Linux
PHP version: 7.2.19
Package: Date/time related
Bug Type: Bug
Bug description:timezone_open accepts invalid timezone string argument
Description:
------------
timezone_open() accepts undocumented/nonsense/partial timezones.
The docs say "One of the supported timezone names or an offset value"
but accepts seemingly nonsense timezones without failure, and timezones
found in the first non-whitespace block in the argument string.
Test script:
---------------
$tz = timezone_open("x UTC");
echo '"x UTC" = '; var_dump($tz);
$tz = timezone_open("c");
echo '"c" = '; var_dump($tz);
$tz = timezone_open("xx UTC");
echo '"xx UTC" = '; var_dump($tz);
$tz = timezone_open("xUTC");
echo '"xUTC" = '; var_dump($tz);
$tz = timezone_open("UTCx");
echo '"UTCx" = '; var_dump($tz);
$tz = timezone_open("UTC xx");
echo '"UTC xx" = '; var_dump($tz);
Expected result:
----------------
"x UTC" = bool(false)
"c" = bool(false)
"xx UTC" = bool(false)
"xUTC" = bool(false)
"UTCx" = bool(false)
"UTC xx" = bool(false)
Actual result:
--------------
"x UTC" = object(DateTimeZone)#127 (2) {
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "X"
}
"c" = object(DateTimeZone)#128 (2) {
["timezone_type"]=>
int(2)
["timezone"]=>
string(1) "C"
}
"xx UTC" = bool(false)
"xUTC" = bool(false)
"UTCx" = bool(false)
"UTC xx" = object(DateTimeZone)#128 (2) {
["timezone_type"]=>
int(3)
["timezone"]=>
string(3) "UTC"
}
--
Edit bug report at https://bugs.php.net/bug.php?id=78139&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=78139&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=78139&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=78139&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=78139&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=78139&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=78139&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=78139&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=78139&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=78139&r=support
Expected behavior: https://bugs.php.net/fix.php?id=78139&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=78139&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=78139&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=78139&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=78139&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=78139&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=78139&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=78139&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=78139&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=78139&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=78139&r=mysqlcfg