Bug->Req #69497 [Opn]: new DateTime('midnighty') should not be accepted
Edit report at https://bugs.php.net/bug.php?id=69497&edit=1
ID: 69497
Updated by: requinix@php.net
Reported by: php at christian-stuedemann dot de
-Summary: new DateTime('midnighty') is accepted
+Summary: new DateTime('midnighty') should not be accepted
Status: Open
-Type: Bug
+Type: Feature/Change Request
Package: Date/time related
PHP Version: 5.6.8
Block user comment: N
Private report: N
New Comment:
The trailing letter is actually being interpreted as a timezone. The whole thing fits the general
scheme of time + timezone so it's accepted: "midnighty" = "midnight" +
"y" = 00:00:00 UTC-12.
http://3v4l.org/gDR6n
http://en.wikipedia.org/wiki/List_of_military_time_zones
Rather than close this, I'm turning it into a feature request that (eg,) keywords like
"midnight" should stand alone and need some kind of word boundary afterwards. Bit of a BC
break but I figure the current behavior too easy to mistake as a bug and I doubt it's used
intentionally that often.
Previous Comments:
------------------------------------------------------------------------
[2015-06-02 16:06:32] anikanov dot d at live dot ru
I have the same issue. I am think the problem in "re2c".
Generated file contain unnecessary lines like 23142 - 23144.
https://github.com/php/php-src/blob/master/ext/date/lib/parse_date.c#L23142
------------------------------------------------------------------------
[2015-04-21 13:18:24] php at christian-stuedemann dot de
Description:
------------
---
From manual page: http://www.php.net/datetime.construct
---
Even if it's a misspelling of the documented date format, an additional character added to the
end of 'midnight' (e.g. 'midnighty' or 'midnighta') is accepted by the
DateTime constructor. Longer terms (like 'midnightyyyy') are not accepted and throw an
Exception like expected.
Test script:
---------------
try {
new DateTime('midnighty');
return 'this might never be returned, bug found';
}catch(Exception $e){
return 'bug fixed';
}
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69497&edit=1
Thread (5 messages)