Skip to content

Commit 92b0f67

Browse files
committed
There's no guard against unparsed characters at the end of the date string, any extra characters are just ignored
Fixes #7244 - Datepicker: parseDate() does not throw an exception for long years
1 parent ba6dd5c commit 92b0f67

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

tests/unit/datepicker/datepicker_tickets.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@ test('Ticket 6827: formatDate day of year calculation is wrong during day lights
2929
equals(time, "089");
3030
});
3131

32+
test('Ticket #7244: date parser does not fail when too many numbers are passed into the date function', function() {
33+
expect(1);
34+
try{
35+
var date = $.datepicker.parseDate('dd/mm/yy', '18/04/19881');
36+
}catch(e){
37+
ok("invalid date detected");
38+
}
39+
});
40+
3241
})(jQuery);

ui/jquery.ui.datepicker.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,9 @@ $.extend(Datepicker.prototype, {
10821082
checkLiteral();
10831083
}
10841084
}
1085+
if (iValue < value.length){
1086+
throw "Extra/unparsed characters found in date: " + value.substring(iValue);
1087+
}
10851088
if (year == -1)
10861089
year = new Date().getFullYear();
10871090
else if (year < 100)

0 commit comments

Comments
 (0)