Closed Bug 1557650 Opened 5 years ago Closed 5 months ago

Date parser parses ISO dates later than 9999 as invalid

Categories

(Core :: JavaScript: Standard Library, defect, P3)

67 Branch
Desktop
All
defect

Tracking

()

VERIFIED FIXED
120 Branch
Tracking Status
firefox-esr115 --- wontfix
firefox69 --- wontfix
firefox118 --- wontfix
firefox119 --- wontfix
firefox120 --- verified
firefox121 --- verified

People

(Reporter: peter.wagner, Assigned: vinny.diehl)

References

(Blocks 1 open bug)

Details

(4 keywords)

Attachments

(2 files)

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:

  1. Open Firefox Console
  2. 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

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/

Flags: needinfo?(peter.wagner)

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

Flags: needinfo?(peter.wagner)

Dear Marcela,

May I ask an update regarding this case, please?

Thank you in advance.

Best regards,

Peter

Flags: needinfo?(tgrabowski)

Do other browsers parse the five digits year correctly? (At least IE 11 didn't.)

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,

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

Status: UNCONFIRMED → NEW
Component: Untriaged → HTML: Parser
Ever confirmed: true
Product: Firefox → Core
Component: HTML: Parser → JavaScript Engine

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

(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 (日本標準時)"

(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-years

new 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

Flags: needinfo?(tgrabowski)
Blocks: 1274354
Priority: -- → P3
Component: JavaScript Engine → JavaScript: Standard Library
Severity: normal → S3

Worth noting in the title that this bug only affects ISO dates. I have a patch incoming.

Assignee: nobody → vinny.diehl
Status: NEW → ASSIGNED
Summary: Date parser parses dates later than 9999 as invalid → Date parser parses ISO dates later than 9999 as invalid
Attachment #9356306 - Attachment description: Bug 1557650 - Allow ISO date years up to 275759 r?arai → WIP: Bug 1557650 - Allow ISO-style dates with year >9999 r?arai
Attachment #9356306 - Attachment description: WIP: Bug 1557650 - Allow ISO-style dates with year >9999 r?arai → Bug 1557650 - Allow ISO-style dates with year >9999 r?arai
Attachment #9356306 - Attachment description: Bug 1557650 - Allow ISO-style dates with year >9999 r?arai → Bug 1557650 - Allow non-formal ISO-style dates r?arai
Attachment #9356306 - Attachment description: Bug 1557650 - Allow non-formal ISO-style dates r?arai → Bug 1557650 - Add support for numeric dashed dates r?arai
Duplicate of this bug: 1275498
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/ebf69344f50d
Add support for numeric dashed dates r=arai

Backed out for causing failures on parse-dashed-numeric-date.js

Backout link

Push with failures

Failure log

There's another failure caused by the same issue: Failure log

Flags: needinfo?(vinny.diehl)

There was a problem with my tests, fixed.

Flags: needinfo?(vinny.diehl)
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/64870045a265
Add support for numeric dashed dates r=arai

Backed out for causing remote failures on browser_RemoteValue.js

[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 - 
Flags: needinfo?(vinny.diehl)
Flags: needinfo?(vinny.diehl)
Duplicate of this bug: 1617258
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/autoland/rev/421ffc7aa24a
Add support for numeric dashed dates r=arai,webdriver-reviewers
Status: ASSIGNED → RESOLVED
Closed: 5 months ago
Resolution: --- → FIXED
Target Milestone: --- → 120 Branch

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.

Flags: needinfo?(vinny.diehl)

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

Flags: needinfo?(vinny.diehl)
Regressions: 1859749
Attachment #9359959 - Flags: approval-mozilla-beta?

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
See Also: → 1858851

Comment on attachment 9359959 [details]
Bug 1557650 - Fix string overflow in Date.parse

Approved for 120.0b2

Attachment #9359959 - Flags: approval-mozilla-beta? → approval-mozilla-beta+
Flags: qe-verify+
QA Whiteboard: [qa-triaged]

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.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
OS: Unspecified → All
Hardware: Unspecified → Desktop
Duplicate of this bug: 1776191
Keywords: dev-doc-needed
Regressions: 1866811
You need to log in before you can comment on or make changes to this bug.