diff --git a/tests/unit/datepicker/datepicker_tickets.js b/tests/unit/datepicker/datepicker_tickets.js index 2b9ce05de..d5249f905 100644 --- a/tests/unit/datepicker/datepicker_tickets.js +++ b/tests/unit/datepicker/datepicker_tickets.js @@ -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); diff --git a/ui/jquery.ui.datepicker.js b/ui/jquery.ui.datepicker.js index 021041202..4c73bdfd8 100644 --- a/ui/jquery.ui.datepicker.js +++ b/ui/jquery.ui.datepicker.js @@ -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)