[wp-trac] [WordPress Trac] #51721: wp-admin/js/post.(min.)js does not successfully validate post dates within years 0000—0100
WordPress Trac
noreply at wordpress.org
Fri Nov 6 15:29:43 UTC 2020
#51721: wp-admin/js/post.(min.)js does not successfully validate post dates within
years 0000—0100
----------------------------+-----------------------------
Reporter: wongjn | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Keywords:
Focuses: ui, javascript |
----------------------------+-----------------------------
When adding or editing a post, `wp-admin/js/post.(min.)js` does not
correctly set the year on a JavaScript `Date` object when validating the
post date.
== To reproduce:
1. Add or edit a post
2. In the ''Publish'' meta box, click ''Edit'' next to the publish date.
3. Enter a validate date, with the year in the range 0—100.
4. See that the date input is highlighted red and marked invalid.
== In depth
This happens because in JavaScript, when passing a two-digit year to the
`Date` constructor, it thinks that it is for the 1900 century. Even
passing a string such as `0050` seems to be type-casted to a number.
[http://developer.mozilla.org/en-
US/docs/Web/JavaScript/Reference/Global_Objects/Date#Two_digit_years_map_to_1900_%E2%80%93_1999
See more on MDN].
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51721>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list