Title: [110331] trunk
Revision
110331
Author
[email protected]
Date
2012-03-09 14:31:55 -0800 (Fri, 09 Mar 2012)

Log Message

REGRESSION: Date.parse("Tue Nov 23 20:40:05 2010 GMT") returns NaN
https://bugs.webkit.org/show_bug.cgi?id=49989

Reviewed by Oliver Hunt.

Patch originally by chris reiss <[email protected]>,
allow the year to appear before the timezone in date strings.

Source/_javascript_Core: 

* wtf/DateMath.cpp:
(WTF::parseDateFromNullTerminatedCharacters):

LayoutTests: 

* fast/js/date-parse-test-expected.txt:
* fast/js/script-tests/date-parse-test.js:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (110330 => 110331)


--- trunk/LayoutTests/ChangeLog	2012-03-09 22:24:17 UTC (rev 110330)
+++ trunk/LayoutTests/ChangeLog	2012-03-09 22:31:55 UTC (rev 110331)
@@ -1,3 +1,16 @@
+2012-03-09  Gavin Barraclough  <[email protected]>
+
+        REGRESSION: Date.parse("Tue Nov 23 20:40:05 2010 GMT") returns NaN
+        https://bugs.webkit.org/show_bug.cgi?id=49989
+
+        Reviewed by Oliver Hunt.
+
+        Patch originally by chris reiss <[email protected]>,
+        allow the year to appear before the timezone in date strings.
+
+        * fast/js/date-parse-test-expected.txt:
+        * fast/js/script-tests/date-parse-test.js:
+
 2012-03-09  Ojan Vafai  <[email protected]>
 
         Move some results from mac-future to mac. mac-future should not exist.

Modified: trunk/LayoutTests/fast/js/date-parse-test-expected.txt (110330 => 110331)


--- trunk/LayoutTests/fast/js/date-parse-test-expected.txt	2012-03-09 22:24:17 UTC (rev 110330)
+++ trunk/LayoutTests/fast/js/date-parse-test-expected.txt	2012-03-09 22:31:55 UTC (rev 110331)
@@ -250,6 +250,13 @@
 PASS Date.parse("Wed Dec 25 1995 1:30 GMT") == 819855000000 is true
 PASS Date.parse("WED DEC 25 1995 1:30 GMT") == 819855000000 is true
 PASS Date.parse("wed dec 25 1995 1:30 gmt") == 819855000000 is true
+PASS Date.parse("Wed Dec 25 1:30 1995 GMT") == 819855000000 is true
+PASS Date.parse("WED DEC 25 1:30 1995 GMT") == 819855000000 is true
+PASS Date.parse("wed dec 25 1:30 1995 gmt") == 819855000000 is true
+PASS Date.parse("Wed Dec 25 1:30 1995GMT") == 819855000000 is true
+PASS Date.parse("Wed Dec 25 1:30 1995 2010 GMT") is NaN
+PASS Date.parse("Wed Dec 25 1:30 1995r GMT") is NaN
+PASS Date.parse("Wed 1:30 Dec 25 GMT") is NaN
 PASS Date.parse("Wed Dec 25 1995 01:30 +0000") == 819855000000 is true
 PASS Date.parse("WED DEC 25 1995 01:30 +0000") == 819855000000 is true
 PASS Date.parse("wed dec 25 1995 01:30 +0000") == 819855000000 is true

Modified: trunk/LayoutTests/fast/js/script-tests/date-parse-test.js (110330 => 110331)


--- trunk/LayoutTests/fast/js/script-tests/date-parse-test.js	2012-03-09 22:24:17 UTC (rev 110330)
+++ trunk/LayoutTests/fast/js/script-tests/date-parse-test.js	2012-03-09 22:31:55 UTC (rev 110331)
@@ -206,6 +206,11 @@
 testDateParse("Anf 25 1995 GMT", "NaN");
 
 testDateParse("Wed Dec 25 1995 1:30 GMT", "819855000000");
+testDateParse("Wed Dec 25 1:30 1995 GMT", "819855000000");
+testDateParseExact("Wed Dec 25 1:30 1995GMT", "819855000000");
+testDateParseExact("Wed Dec 25 1:30 1995 2010 GMT", "NaN");
+testDateParseExact("Wed Dec 25 1:30 1995r GMT", "NaN");
+testDateParseExact("Wed 1:30 Dec 25 GMT", "NaN");
 
 // RFC 2822
 testDateParse("Wed Dec 25 1995 01:30 +0000", "819855000000");

Modified: trunk/Source/_javascript_Core/ChangeLog (110330 => 110331)


--- trunk/Source/_javascript_Core/ChangeLog	2012-03-09 22:24:17 UTC (rev 110330)
+++ trunk/Source/_javascript_Core/ChangeLog	2012-03-09 22:31:55 UTC (rev 110331)
@@ -1,3 +1,16 @@
+2012-03-09  Gavin Barraclough  <[email protected]>
+
+        REGRESSION: Date.parse("Tue Nov 23 20:40:05 2010 GMT") returns NaN
+        https://bugs.webkit.org/show_bug.cgi?id=49989
+
+        Reviewed by Oliver Hunt.
+
+        Patch originally by chris reiss <[email protected]>,
+        allow the year to appear before the timezone in date strings.
+
+        * wtf/DateMath.cpp:
+        (WTF::parseDateFromNullTerminatedCharacters):
+
 2012-03-09  Mark Rowe  <[email protected]>
 
         Ensure that the WTF headers are copied at installhdrs time.

Modified: trunk/Source/_javascript_Core/wtf/DateMath.cpp (110330 => 110331)


--- trunk/Source/_javascript_Core/wtf/DateMath.cpp	2012-03-09 22:24:17 UTC (rev 110330)
+++ trunk/Source/_javascript_Core/wtf/DateMath.cpp	2012-03-09 22:31:55 UTC (rev 110331)
@@ -935,6 +935,14 @@
             }
         }
     }
+    
+    // The year may be after the time but before the time zone.
+    if (isASCIIDigit(*dateString) && year == -1) {
+        if (!parseLong(dateString, &newPosStr, 10, &year))
+            return std::numeric_limits<double>::quiet_NaN();
+        dateString = newPosStr;
+        skipSpacesAndComments(dateString);
+    }
 
     // Don't fail if the time zone is missing. 
     // Some websites omit the time zone (4275206).
@@ -987,10 +995,9 @@
         if (!parseLong(dateString, &newPosStr, 10, &year))
             return std::numeric_limits<double>::quiet_NaN();
         dateString = newPosStr;
+        skipSpacesAndComments(dateString);
     }
 
-    skipSpacesAndComments(dateString);
-
     // Trailing garbage
     if (*dateString)
         return std::numeric_limits<double>::quiet_NaN();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to