Skip to content

Commit caf2916

Browse files
Escape special chars as separator (fix by elzoiddy)
1 parent 1a2a371 commit caf2916

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

jquery-ui-timepicker-addon.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,9 @@ $.extend(Timepicker.prototype, {
208208
// the time should come after x number of characters and a space.
209209
// x = at least the length of text specified by the date format
210210
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
211-
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr;
211+
// escape special regex characters in the seperator
212+
var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g");
213+
regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator.replace(specials, "\\$&") + regstr;
212214
}
213215

214216
treg = timeString.match(new RegExp(regstr, 'i'));

0 commit comments

Comments
 (0)