RESOLVED FIXED Bug 13472
Misparsing date in javascript leads to year value of -1
https://bugs.webkit.org/show_bug.cgi?id=13472
Summary Misparsing date in javascript leads to year value of -1
John McKerrell
Reported 2007-04-24 08:05:08 PDT
Simple test case given in the URL, copied here in case of problems: javascript:void(alert(new Date( '24 May,2007 15:35:00' ) ) ) If a space is added after the comma, the parse succeeds, without the space it gives the incorrect year.
Attachments
First attempt (1.44 KB, patch)
2007-09-18 12:09 PDT, Rob Buis
no flags
Updated patch (1.85 KB, patch)
2007-09-18 12:54 PDT, Rob Buis
no flags
Now with testcase (5.62 KB, patch)
2007-09-18 23:56 PDT, Rob Buis
aroben: review+
David Kilzer (:ddkilzer)
Comment 1 2007-04-24 09:32:01 PDT
Confirmed with a local debug build of WebKit r21060 on Safari 2.0.4 (419.3) on Mac OS X 10.4.9 (8P135). Firefox 2.0.0.3 parses it correctly, as does Mac IE 5.2.3 and Opera 9.10. OmniWeb 5.5.3 suffers from the same bug as WebKit.
David Kilzer (:ddkilzer)
Comment 2 2007-04-24 09:33:36 PDT
Not a regression as the same misparsing occurs in shipping Safari 2.0.4 (419.3) on Mac OS X 10.4.9 (8P135).
Rob Buis
Comment 3 2007-09-18 12:09:45 PDT
Created attachment 16315 [details] First attempt This patch should fix the problem. However there are some things I am wondering about: - mozilla is very liberal with ',', basically making it act as whitespace and things like this work: javascript:void(alert(new Date( '24 May,,,,,,2007 15:35:00' ))) I wonder if we want to go that way? - not sure where to add/change a testcase for this? Cheers, Rob.
Darin Adler
Comment 4 2007-09-18 12:43:00 PDT
Comment on attachment 16315 [details] First attempt I suggest putting the test case in LayoutTests/fast/js.
Rob Buis
Comment 5 2007-09-18 12:54:28 PDT
Created attachment 16316 [details] Updated patch Updating the patch with a fix for bug 14176, since they are pretty similar. Cheers, Rob.
David Kilzer (:ddkilzer)
Comment 6 2007-09-18 13:07:35 PDT
You should also run WebKitTools/Scripts/run-javascript-tests to make sure there are no regressions and to update the results if there are progressions!
Rob Buis
Comment 7 2007-09-18 23:56:42 PDT
Created attachment 16321 [details] Now with testcase I updated the patch with some added tests in the directory Darin pointed out. Cheers, Rob.
Adam Roben (:aroben)
Comment 8 2007-09-22 14:46:01 PDT
Comment on attachment 16321 [details] Now with testcase + while (*dateString && (*dateString != '-' && *dateString != ',') && !isspace(*dateString)) The parentheses around (*dateString != '-' && *dateString != ',') should not be necessary. + if (*dateString != '-' && *dateString != '/' && !isspace(*dateString) && *dateString != ',') It would be a little nicer to put the comma check after the slash check, but that's a real nitpick.
Adam Roben (:aroben)
Comment 9 2007-09-28 11:47:28 PDT
Comment on attachment 16321 [details] Now with testcase r=me even if the above comments aren't fixed. Please land this on feature-branch.
Rob Buis
Comment 10 2007-09-29 01:39:36 PDT
Hi Adam, (In reply to comment #9) > (From update of attachment 16321 [details] [edit]) > r=me even if the above comments aren't fixed. > > Please land this on feature-branch. I just did, including taking your comments into account. Unfortunately I had to tweak it slightly to make it pass the test, I am not sure why, but the same fix works on trunk. Cheers, Rob.
Rob Buis
Comment 11 2007-10-03 08:45:05 PDT
I guess this can be closed now. Cheers, Rob.
Note You need to log in before you can comment on or make changes to this bug.