]> 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:30:26 +0000 (17:30 +0200)
Fixes #7244 - Datepicker: parseDate() does not throw an exception for long years

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

index 2b9ce05de681d718487f9d886979a9708b227665..d5249f9051dced0afbfb77ea36ea80f0107ffa6b 100644 (file)
@@ -29,4 +29,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 021041202ed9772cd8975ee5c9dcbe374000fd95..4c73bdfd8e36eb94701f893b2e02850a8c1a8b15 100644 (file)
@@ -1082,6 +1082,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)