Date parser parses ISO dates later than 9999 as invalid
Categories
(Core :: JavaScript: Standard Library, defect, P3)
Tracking
()
People
(Reporter: peter.wagner, Assigned: vinny.diehl)
References
(Blocks 1 open bug)
Details
(4 keywords)
Attachments
(2 files)
|
48 bytes,
text/x-phabricator-request
|
Details | Review | |
|
48 bytes,
text/x-phabricator-request
|
diannaS
:
approval-mozilla-beta+
|
Details | Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.80 Safari/537.36
Steps to reproduce:
- Open Firefox Console
- Type in the following:
new Date("9999-11-11")
Date 9999-11-11T00:00:00.000Z
new Date("19999-11-11")
Invalid Date
Actual results:
See above
Expected results:
Both dates should be valid
Comment 1•6 years ago
|
||
Hi peter.wagner!
I was unable to reproduce this issue.
I have tested on lates Nightly 69.0a1 (2019-06-11) (64-bit) and this was my result:
new Date("9999-11-11")
Date Wed Nov 10 9999 21:00:00 GMT-0300 (Argentina Standard Time)
Could you please try to retest this on the latest Nightly Version?
You can download to https://www.mozilla.org/en-US/firefox/nightly/all/
| Reporter | ||
Comment 2•6 years ago
|
||
Hi Marcela,
Unfortunately, I have to highlight that your test case isn't the reported one.
The problem is there when you are trying it where the year is five digits, in my example:
new Date("19999-11-11")
Invalid Date
The problem can be caused by a typo from the end-user, for example.
I repeated my tests in Firefox Nightly 69.0a1 (2019-06-12) (64-bit) with the exact same results.
new Date("9999-11-11")
Date Thu Nov 11 9999 01:00:00 GMT+0100 (Central European Standard Time)
new Date("19999-11-11")
Invalid Date
Thank you in advance for your assistance and feedback.
Best regards,
Peter
| Reporter | ||
Comment 3•6 years ago
|
||
Dear Marcela,
May I ask an update regarding this case, please?
Thank you in advance.
Best regards,
Peter
Comment 4•6 years ago
|
||
Do other browsers parse the five digits year correctly? (At least IE 11 didn't.)
| Reporter | ||
Comment 5•6 years ago
|
||
Dear Masatoshi, Dear Marcela,
In my tests it was working well with:
Microsoft EdgeHTML 17.17134 42.17134.1.0 and Google Chrome Version 75.0.3770.90 (Official Build) (64-bit).
I also can confirm that it doesn't work with Internet Explorer Version 11.829.17134.0 Update versions: 11.0.130 (KB4503259).
Thank you in advance for your work with this case.
Best regards,
Comment 6•6 years ago
|
||
I was able to reproduce on latest Nightly 69.0a1 (2019-06-18).
new Date("9999-11-11")
Date Wed Nov 10 9999 21:00:00 GMT-0300 (Argentina Standard Time)
new Date("19999-11-11")
Invalid Date
Updated•6 years ago
|
| Reporter | ||
Comment 7•6 years ago
|
||
Dear Marcela,
I'm just wondering if you have any further information regarding this case after reproduction, or any known workaround until a final solution would be applicable?
Thank you in advance for your feedback.
Best regards,
Peter
Comment 8•6 years ago
|
||
(In reply to peter.wagner from comment #7)
or any known workaround until a final solution would be applicable?
Please use ISO 8601 Extended Format. It is guaranteed to work with all ECMA-262 compliant implementations:
https://www.ecma-international.org/ecma-262/9.0/index.html#sec-extended-years
new Date("+019999-11-11").toString()
"Thu Nov 11 19999 09:00:00 GMT+0900 (日本標準時)"
| Reporter | ||
Comment 9•6 years ago
|
||
(In reply to Masatoshi Kimura [:emk] from comment #8)
(In reply to peter.wagner from comment #7)
or any known workaround until a final solution would be applicable?
Please use ISO 8601 Extended Format. It is guaranteed to work with all ECMA-262 compliant implementations:
https://www.ecma-international.org/ecma-262/9.0/index.html#sec-extended-yearsnew Date("+019999-11-11").toString() "Thu Nov 11 19999 09:00:00 GMT+0900 (日本標準時)"
Dear Masatoshi,
Thank you so much, I'm checking this.
Best regards,
Peter
Updated•6 years ago
|
Updated•6 years ago
|
Updated•6 years ago
|
Updated•3 years ago
|
| Assignee | ||
Comment 10•2 years ago
|
||
Worth noting in the title that this bug only affects ISO dates. I have a patch incoming.
| Assignee | ||
Comment 11•2 years ago
|
||
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 13•2 years ago
|
||
Comment 14•2 years ago
|
||
Backed out for causing failures on parse-dashed-numeric-date.js
There's another failure caused by the same issue: Failure log
| Assignee | ||
Comment 15•2 years ago
|
||
There was a problem with my tests, fixed.
Comment 16•2 years ago
|
||
Comment 17•2 years ago
|
||
Backed out for causing remote failures on browser_RemoteValue.js
- backout: https://hg.mozilla.org/integration/autoland/rev/937dc144e6ad5dbf1fbbd4cfe26adae5dc0ce06d
- push: https://treeherder.mozilla.org/jobs?repo=autoland&group_state=expanded&selectedTaskRun=JsBHH-nZRBmJuv8zgmeDCg.0&revision=64870045a265fc41ca5126b54d14dd258aca41b4
- failure log: https://treeherder.mozilla.org/logviewer?job_id=432391739&repo=autoland&lineNumber=55101
[task 2023-10-13T12:58:57.186Z] 12:58:57 INFO - TEST-PASS | remote/webdriver-bidi/test/browser/browser_RemoteValue.js | . Got expected error for date string: 2009-02-50 -
[task 2023-10-13T12:58:57.187Z] 12:58:57 INFO - Checking '2022-02-29'
[task 2023-10-13T12:58:57.188Z] 12:58:57 INFO - Buffered messages finished
[task 2023-10-13T12:58:57.199Z] 12:58:57 INFO - TEST-UNEXPECTED-FAIL | remote/webdriver-bidi/test/browser/browser_RemoteValue.js | Missing expected exception. Got expected error for date string: 2022-02-29 - {"filename":"chrome://mochitests/content/browser/remote/webdriver-bidi/test/browser/browser_RemoteValue.js","name":"test_deserializeDateLocalValueInvalidValues","sourceId":601,"lineNumber":624,"columnNumber":12,"sourceLine":"","asyncCause":null,"asyncCaller":null,"caller":{"filename":"chrome://mochikit/content/browser-test.js","name":"handleTask","sourceId":551,"lineNumber":1134,"columnNumber":26,"sourceLine":"","asyncCause":null,"asyncCaller":null,"caller":{"filename":"chrome://mochikit/content/browser-test.js","name":"_runTaskBasedTest","sourceId":551,"lineNumber":1206,"columnNumber":18,"sourceLine":"","asyncCause":null,"asyncCaller":{"filename":"chrome://mochikit/content/browser-test.js","name":"Tester_execTest","sourceId":551,"lineNumber":1348,"columnNumber":14,"sourceLine":"","asyncCause":null,"asyncCaller":null,"caller":{"filename":"chrome://mochikit/content/browser-test.js","name":"nextTest/<","sourceId":551,"lineNumber":1123,"columnNumber":14,"sourceLine":"","asyncCause":null,"asyncCaller":null,"caller":{"filename":"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js","name":"SimpleTest.waitForFocus/<","sourceId":578,"lineNumber":1058,"columnNumber":13,"sourceLine":"","asyncCause":null,"asyncCaller":null,"caller":null,"formattedStack":"SimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}},"formattedStack":"nextTest/<@chrome://mochikit/content/browser-test.js:1123:14\nSimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}},"formattedStack":"async*Tester_execTest@chrome://mochikit/content/browser-test.js:1348:14\nnextTest/<@chrome://mochikit/content/browser-test.js:1123:14\nSimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}},"caller":null,"formattedStack":"_runTaskBasedTest@chrome://mochikit/content/browser-test.js:1206:18\nasync*Tester_execTest@chrome://mochikit/content/browser-test.js:1348:14\nnextTest/<@chrome://mochikit/content/browser-test.js:1123:14\nSimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}},"formattedStack":"handleTask@chrome://mochikit/content/browser-test.js:1134:26\n_runTaskBasedTest@chrome://mochikit/content/browser-test.js:1206:18\nasync*Tester_execTest@chrome://mochikit/content/browser-test.js:1348:14\nnextTest/<@chrome://mochikit/content/browser-test.js:1123:14\nSimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}},"formattedStack":"test_deserializeDateLocalValueInvalidValues@chrome://mochitests/content/browser/remote/webdriver-bidi/test/browser/browser_RemoteValue.js:624:12\nhandleTask@chrome://mochikit/content/browser-test.js:1134:26\n_runTaskBasedTest@chrome://mochikit/content/browser-test.js:1206:18\nasync*Tester_execTest@chrome://mochikit/content/browser-test.js:1348:14\nnextTest/<@chrome://mochikit/content/browser-test.js:1123:14\nSimpleTest.waitForFocus/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:1058:13\n","nativeSavedFrame":{}}
[task 2023-10-13T12:58:57.201Z] 12:58:57 INFO - Stack trace:
[task 2023-10-13T12:58:57.202Z] 12:58:57 INFO - chrome://mochitests/content/browser/remote/webdriver-bidi/test/browser/browser_RemoteValue.js:test_deserializeDateLocalValueInvalidValues:624
[task 2023-10-13T12:58:57.203Z] 12:58:57 INFO - chrome://mochikit/content/browser-test.js:handleTask:1134
[task 2023-10-13T12:58:57.204Z] 12:58:57 INFO - chrome://mochikit/content/browser-test.js:_runTaskBasedTest:1206
[task 2023-10-13T12:58:57.205Z] 12:58:57 INFO - chrome://mochikit/content/browser-test.js:Tester_execTest:1348
[task 2023-10-13T12:58:57.206Z] 12:58:57 INFO - chrome://mochikit/content/browser-test.js:nextTest/<:1123
[task 2023-10-13T12:58:57.207Z] 12:58:57 INFO - chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:SimpleTest.waitForFocus/<:1058
[task 2023-10-13T12:58:57.208Z] 12:58:57 INFO - TEST-PASS | remote/webdriver-bidi/test/browser/browser_RemoteValue.js | . Got expected error for date string: 2022-02-29 -
| Assignee | ||
Comment 18•2 years ago
|
||
Mochitests are good now: https://treeherder.mozilla.org/jobs?repo=try&revision=466e7a16d67596bea176ae788e8ce90be3d6caea
Comment 20•2 years ago
|
||
Comment 21•2 years ago
|
||
| bugherder | ||
Comment 22•2 years ago
•
|
||
Vinny, not sure but I wonder if this change in behavior should be relnoted (especially the rollover behavior)? Maybe it would be enough to do that on MDN.
| Assignee | ||
Comment 23•2 years ago
|
||
The rollover behavior isn't new, per se; it manifests for most formats:
> eshost -te 'new Date("Feb 31, 2002")'
| Engine | Result |
|---|---|
| JavaScriptCore | Sun Mar 03 2002 00:00:00 GMT-0700 (Mountain Standard Time) |
| SpiderMonkey | Sun Mar 03 2002 00:00:00 GMT-0700 (Mountain Standard Time) |
| V8 | Sun Mar 03 2002 00:00:00 GMT-0700 (Mountain Standard Time) |
What is new, however, is the acceptance of numeric dashed date formats which are not formatted to the ISO standard. This standard rejects mdays which are out-of-bounds of a given month, which is why cases such as "2002-02-31" had been rejected. With this change, dashed dates such as this which don't conform to the standard but are still a reasonable date will be parsed with the same behavior as most typical date formats, which includes this rollover behavior, as well as being in the local time zone by default.
This should definitely be relnoted. I've drafted a PR for MDN: https://github.com/mdn/content/pull/29702
Updated•2 years ago
|
| Assignee | ||
Comment 24•2 years ago
|
||
Updated•2 years ago
|
Comment 25•2 years ago
|
||
Uplift Approval Request
- Code covered by automated testing: yes
- User impact if declined: Single-character string overflow causing intermittent rejected dashed Date formats which should be accepted.
- String changes made/needed: N/A
- Is Android affected?: yes
- Steps to reproduce for manual QE testing: N/A
- Needs manual QE test: no
- Fix verified in Nightly: yes
- Risk associated with taking this patch: Low
- Explanation of risk level: Simple overflow fix
Comment 26•2 years ago
|
||
Comment on attachment 9359959 [details]
Bug 1557650 - Fix string overflow in Date.parse
Approved for 120.0b2
Comment 27•2 years ago
|
||
| uplift | ||
Updated•2 years ago
|
Updated•2 years ago
|
Comment 28•2 years ago
•
|
||
This fix has been verified in Nightly v120.0a1 and v121.0a1, then on Beta v120.0b2 and Developer Edition v120.0b2 on Windows 10, MacOS 11 and Ubuntu 22. Dates with 5-digit year are now valid.
Updated•2 years ago
|
Description
•