]> source.dussan.org Git - jquery-ui.git/commitdiff
There's no guard against unparsed characters at the end of the date string, any extra...
authorJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 18 May 2011 15:30:26 +0000 (17:30 +0200)
committerJörn Zaefferer <joern.zaefferer@gmail.com>
Wed, 18 May 2011 15:35:57 +0000 (17:35 +0200)
Fixes #7244 - Datepicker: parseDate() does not throw an exception for long years
(cherry picked from commit 92b0f6702a9408f4bd7d71ccca7e0e851d0efc6b)

tests/unit/datepicker/datepicker_tickets.js
ui/jquery.ui.datepicker.js

index 841e404057a41afa978fb7e13d8df180d3252912..c7fde60decea6cff6eb05456afa9112fad9c67d3 100644 (file)
@@ -34,4 +34,13 @@ test('Ticket 6827: formatDate day of year calculation is wrong during day lights
     equals(time, "089");
 });
 
+test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
+    expect(1);
+    try{
+        var date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
+    }catch(e){
+        ok("invalid date detected");
+    }
+});
+
 })(jQuery);
index 045fa1d92d835d2057aa1794daa3d6345f66081e..6681d693c71b7db8bfc8e2d97c77c5b33e140022 100644 (file)
@@ -1078,6 +1078,9 @@ $.extend(Datepicker.prototype, {
                                                checkLiteral();
                                }
                }
+               if (iValue < value.length){
+                       throw "Extra/unparsed characters found in date: " + value.substring(iValue);
+               }
                if (year == -1)
                        year = new Date().getFullYear();
                else if (year < 100)