Repository navigation
[2.x] Validate the date-time format without Ethlo with the time format rules (#1316) - #1336
Conversation
The java.time fallback accepted a time without seconds, an offset without minutes or with seconds and an empty fraction, and rejected a leap second and an offset beyond 18:00. It now parses the date on its own and checks the time with the rules of the time format. Refs networknt#1316
|
Review notes. This branch's source and tests are identical to the master PR (#1335), so the same findings apply. I built the 2.x branch and
Details and repro values are in the comment on #1335. |
…llback Review of networknt#1335: a leap second has to be at the end of a June 30 or a December 31 in UTC, the hour and minute of a leap second are range checked, a time without seconds is rejected explicitly, and the date goes through DateFormat. Refs networknt#1316
|
Thanks for the review, all of it is in the second commit (9118992, cherry-picked to #1336 as dc8d957).
|
|
Same commits cherry-picked, see #1335. |
|
Thanks for the second commit. I re-reviewed dc8d957 against the master PR (#1335). The source is identical, and
|
…hout Ethlo Review of networknt#1335: TimeFormat.parse returns the fields of a full-time and the date-time fallback uses them for the leap second date instead of reading the string again. The time format change gets its own CHANGELOG line, and a test loads the library without Ethlo and validates date-time through a schema. Refs networknt#1316
2.x counterpart of #1335. Refs #1316, the fallback items: the empty fraction, the missing seconds and the hour-only offset that
JavaTimeOffsetDateTime.isValidaccepts without Ethlo. The Ethlo items (-00:00, offsets past ±18:00, fractions longer than 9 digits) are not in here.Problem
Without Ethlo on the classpath,
date-timeon 2.x is checked withOffsetDateTime.parse(..), the same as on master:DateFormat.java,DateTimeFormat.javaandTimeFormat.javaare identical on both branches. So 2.x accepts2020-01-01T12:00Z(no seconds),+01(no offset minutes),+01:00:00(offset seconds) and12:00:00.Z(empty fraction), and rejects a leap second, an offset beyond ±18:00 and a fraction longer than nine digits, which RFC 3339 allows andformat: timeaccepts since #1315.Fix
The commits from #1335 cherry-picked as they are, no conflicts. The fallback checks the three parts of
full-date "T" full-timeseparately: theT/tseparator, the date throughDateFormat.isValid(..)and the time throughTimeFormat.parse(..), which returns the parsed fields;isValidon both is the formermatches(..)body. A leap second is accepted only at the end of a June 30 or a December 31 in UTC, after applying the offset.TimeFormatalso gets the range check on the hour and minute of a leap second and the explicitHH:MM:SScheck, soformat: timeon 2.x is fixed with it and has its own CHANGELOG line.With Ethlo on the classpath nothing changes, so Draft 4/6/7 with default settings are not affected.
As on master, one difference between the two paths remains: Ethlo also checks that a leap second was actually inserted on that date, the fallback doesn't carry that table. The CHANGELOG says so.
Tests
The same tests as in #1335, including the one that loads the library through a class loader without Ethlo and validates
date-timethrough a schema.DateTimeFormatTest,TimeFormatTestandDateFormatTestpass on 2.x (94 tests). Changelog entries added under Unreleased on 2.x.