Skip to content

Commit df17954

Browse files
committed
Datepicker: Escape single quotes in tooltips. Fixes #9049 - Datepicker beforeShowDay tooltip not displayed properly if single quote is used.
1 parent dddf2a7 commit df17954

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

tests/unit/datepicker/datepicker_options.js

+15
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,21 @@ test("callbacks", function() {
782782
inp.datepicker("hide").datepicker("destroy");
783783
});
784784

785+
test("beforeShowDay - tooltips with quotes", function() {
786+
expect( 1 );
787+
var inp, dp;
788+
inp = TestHelpers.datepicker.init("#inp", {
789+
beforeShowDay: function() {
790+
return [ true, "", "'" ];
791+
}
792+
});
793+
dp = $("#ui-datepicker-div");
794+
795+
inp.datepicker("show");
796+
equal( dp.find( ".ui-datepicker-calendar td:contains('9')").attr( "title" ), "'" );
797+
inp.datepicker("hide").datepicker("destroy");
798+
});
799+
785800
test("localisation", function() {
786801
expect( 24 );
787802
var dp, month, day, date,

ui/jquery.ui.datepicker.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1741,7 +1741,7 @@ $.extend(Datepicker.prototype, {
17411741
(otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
17421742
(printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
17431743
(printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
1744-
((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2] + "'" : "") + // cell title
1744+
((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "'") + "'" : "") + // cell title
17451745
(unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
17461746
(otherMonth && !showOtherMonths ? " " : // display for other months
17471747
(unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +

0 commit comments

Comments
 (0)