Bug #78984 [NEW]: DateTimeZone accepting invalid UTC timezones

From: Date: Tue, 17 Dec 2019 19:14:11 +0000
Subject: Bug #78984 [NEW]: DateTimeZone accepting invalid UTC timezones
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-224371@lists.php.net to get a copy of this message
From: eu+php at redrat dot com dot br Operating system: Linux PHP version: 7.4.0 Package: Date/time related Bug Type: Bug Bug description:DateTimeZone accepting invalid UTC timezones Description: ------------ Today, object \DateTimeZone accepts various timezone format in your construct. One option to instantiate this is using UTC formats like "-3" or "+5", but today UTC have only timezone between -12 and +12 and construct is accepting any number, like in test script. Expected result if you define invalid UTC timezone is fatal error, like when you set other unknown or bad timezone, as described in php_date.c#L3484, but today this object is accepting any integer value and causes mistakes in date time operations. Test script: --------------- <?php var_dump( new \DateTimeZone('-3'), new \DateTimeZone('+3'), new \DateTimeZone('+30157') ); Expected result: ---------------- Fatal error: Uncaught Exception: DateTimeZone::__construct(): Unknown or bad timezone (+30157) in %script% Actual result: -------------- object(DateTimeZone)#1 (2) { ["timezone_type"]=> int(1) ["timezone"]=> string(6) "-03:00" } object(DateTimeZone)#2 (2) { ["timezone_type"]=> int(1) ["timezone"]=> string(6) "+03:00" } object(DateTimeZone)#3 (2) { ["timezone_type"]=> int(1) ["timezone"]=> string(9) "+30157eZ" } -- Edit bug report at https://bugs.php.net/bug.php?id=78984&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=78984&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=78984&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=78984&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=78984&r=needscript Try newer version: https://bugs.php.net/fix.php?id=78984&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=78984&r=support Expected behavior: https://bugs.php.net/fix.php?id=78984&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=78984&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=78984&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=78984&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=78984&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=78984&r=dst IIS Stability: https://bugs.php.net/fix.php?id=78984&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=78984&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=78984&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=78984&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=78984&r=mysqlcfg

« previous php.bugs (#224371) next »