(bug 42607) $.tablesorter: require separators when detecting dates
authorMatmaRex <matma.rex@gmail.com>
Sat, 23 Mar 2013 21:29:51 +0000 (22:29 +0100)
committerMatmaRex <matma.rex@gmail.com>
Sat, 23 Mar 2013 21:29:51 +0000 (22:29 +0100)
$.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

resources/jquery/jquery.tablesorter.js

index e08c9aa..a552237 100644 (file)
                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' );
 
        }