Bug 1550949: Disallow time-only version of ISO8601 r=arai
authorKagami Sascha Rosylight <saschanaz@outlook.com>
Wed, 15 May 2019 14:03:54 +0000
changeset 535832 69c5ef5e60352efbfb03e562eb77c9f30ac32690
parent 535831 02f031c0f789c7b8c21ad281cddad59ba4a9a8a9
child 535833 2cd499a2a7d92aa352bd6e51c58e3c74535fbab5
push id2082
push userffxbld-merge
push dateMon, 01 Jul 2019 08:34:18 +0000
treeherdermozilla-release@2fb19d0466d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarai
bugs1550949
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1550949: Disallow time-only version of ISO8601 r=arai ES5.1 removed time-only format T00:00:00 and no other browsers support it. So this diff removes the support from gecko. Differential Revision: https://phabricator.services.mozilla.com/D31253
js/src/jsdate.cpp
js/src/tests/non262/Date/15.9.4.2.js
js/src/tests/non262/Date/non-iso.js
--- a/js/src/jsdate.cpp
+++ b/js/src/jsdate.cpp
@@ -958,17 +958,17 @@ static bool ParseISOStyleDate(const Char
   }
 
   if (PEEK('+') || PEEK('-')) {
     if (PEEK('-')) {
       dateMul = -1;
     }
     ++i;
     NEED_NDIGITS(6, year);
-  } else if (!PEEK('T')) {
+  } else {
     NEED_NDIGITS(4, year);
   }
   DONE_DATE_UNLESS('-');
   NEED_NDIGITS_OR_LESS(2, month);
   DONE_DATE_UNLESS('-');
   NEED_NDIGITS_OR_LESS(2, day);
 
 done_date:
@@ -1046,16 +1046,17 @@ done:
 
   *result = TimeClip(msec);
   return NumbersAreIdentical(msec, result->toDouble());
 
 #undef PEEK
 #undef NEED
 #undef DONE_UNLESS
 #undef NEED_NDIGITS
+#undef NEED_NDIGITS_OR_LESS
 }
 
 template <typename CharT>
 static bool ParseDate(const CharT* s, size_t length, ClippedTime* result) {
   if (ParseISOStyleDate(s, length, result)) {
     return true;
   }
 
--- a/js/src/tests/non262/Date/15.9.4.2.js
+++ b/js/src/tests/non262/Date/15.9.4.2.js
@@ -60,36 +60,36 @@ function test()
   check("2009-07T19:53:21.001+12:00",    dd(2009,7,1,7,53,21,1));
   check("2009-07T19:53:21+12:00",        dd(2009,7,1,7,53,21,0));
   check("2009-07T19:53+12:00",           dd(2009,7,1,7,53,0,0));
 
   check("2009T19:53:21.001+12:00",       dd(2009,1,1,7,53,21,1));
   check("2009T19:53:21+12:00",           dd(2009,1,1,7,53,21,0));
   check("2009T19:53+12:00",              dd(2009,1,1,7,53,0,0));
 
-  check("T19:53:21.001+12:00",           dd(1970,1,1,7,53,21,1));
-  check("T19:53:21+12:00",               dd(1970,1,1,7,53,21,0));
-  check("T19:53+12:00",                  dd(1970,1,1,7,53,0,0));
+  checkInvalid("T19:53:21.001+12:00");
+  checkInvalid("T19:53:21+12:00");
+  checkInvalid("T19:53+12:00");
 
   // formats without timezone uses the timezone as at that date
   check("2009-07-23T19:53:21.001",       dd(2009,7,23,19,53,21,1)+Jul2009TZ);
   check("2009-07-23T19:53:21",           dd(2009,7,23,19,53,21,0)+Jul2009TZ);
   check("2009-07-23T19:53",              dd(2009,7,23,19,53,0,0)+Jul2009TZ);
 
   check("2009-07T19:53:21.001",          dd(2009,7,1,19,53,21,1)+Jul2009TZ);
   check("2009-07T19:53:21",              dd(2009,7,1,19,53,21,0)+Jul2009TZ);
   check("2009-07T19:53",                 dd(2009,7,1,19,53,0,0)+Jul2009TZ);
 
   check("2009T19:53:21.001",             dd(2009,1,1,19,53,21,1)+Jan2009TZ);
   check("2009T19:53:21",                 dd(2009,1,1,19,53,21,0)+Jan2009TZ);
   check("2009T19:53",                    dd(2009,1,1,19,53,0,0)+Jan2009TZ);
 
-  check("T19:53:21.001",                 dd(1970,1,1,19,53,21,1)+Jan1970TZ);
-  check("T19:53:21",                     dd(1970,1,1,19,53,21,0)+Jan1970TZ);
-  check("T19:53",                        dd(1970,1,1,19,53,0,0)+Jan1970TZ);
+  checkInvalid("T19:53:21.001");
+  checkInvalid("T19:53:21");
+  checkInvalid("T19:53");
 
   // with no time at all assume UTC
   check("2009-07-23",                    dd(2009,7,23,0,0,0,0));
   check("2009-07",                       dd(2009,7,1,0,0,0,0));
   check("2009",                          dd(2009,1,1,0,0,0,0));
 
   // one field too big
   checkInvalid("2009-13-23T19:53:21.001+12:00");
--- a/js/src/tests/non262/Date/non-iso.js
+++ b/js/src/tests/non262/Date/non-iso.js
@@ -34,17 +34,17 @@ assertEq(new Date("1997-03-08 1:19").get
          new Date("1997-03-08T1:19").getTime());
 assertEq(new Date("1997-03-08 1:1").getTime(),
          new Date("1997-03-08T1:1").getTime());
 assertEq(new Date("1997-03-08 1:1:01").getTime(),
          new Date("1997-03-08T1:1:01").getTime());
 assertEq(new Date("1997-03-08 1:1:1").getTime(),
          new Date("1997-03-08T1:1:1").getTime());
 assertEq(new Date("1997-03-08 11").getTime(),
-         new Date("1997-03-08T11").getTime());
+         new Date("1997-03-08T11").getTime()); // Date(NaN)
 assertEq(new Date("1997-03-08").getTime(),
          new Date("1997-03-08").getTime());
 assertEq(new Date("1997-03-8").getTime(),
          new Date("1997-03-08").getTime());
 assertEq(new Date("1997-3-8").getTime(),
          new Date("1997-03-08").getTime());
 assertEq(new Date("1997-3-8 ").getTime(),
          new Date("1997-03-08T").getTime()); // Date(NaN)