(bug 42607) $.tablesorter: require separators when detecting dates

$.tablesorter allowed no separators in DMY- or MDY-formatted dates,
where M is a month taken from the wgMonthNames and wgMonthNamesShort
variables. This was probably intended to capture dates like
'1Dec2012'.

Unfortunately, for example the Czech language uses no short month
names, and the variable simply contains numbers from 1 to 12. This
caused the datection to break horribly and consider all numbers to be
dates.

With this patch, detection requires a space or one of the other
defined separators between month and day or year.

Change-Id: I3a37acf1985eddf922e69e2c2a1cf541fc00e97e
This commit is contained in:
MatmaRex 2013-03-23 22:29:51 +01:00
parent 23a8968cad
commit c1104c2dbd

View file

@ -424,10 +424,10 @@
ts.dateRegex[0] = new RegExp( /^\s*(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{1,2})[\,\.\-\/'\s]{1,2}(\d{2,4})\s*?/i);
// Written Month name, dmy
ts.dateRegex[1] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]*(\\d{2,4})\\s*$', 'i' );
ts.dateRegex[1] = new RegExp( '^\\s*(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
// Written Month name, mdy
ts.dateRegex[2] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]*(\\d{1,2})[\\,\\.\\-\\/\'\\s]*(\\d{2,4})\\s*$', 'i' );
ts.dateRegex[2] = new RegExp( '^\\s*(' + regex + ')' + '[\\,\\.\\-\\/\'\\s]+(\\d{1,2})[\\,\\.\\-\\/\'\\s]+(\\d{2,4})\\s*$', 'i' );
}