Filter: partially revert df1afccdda (see #1505)

Automatic escaping of RegExp special characters must be done
manually as already explained in the documentation
This commit is contained in:
Rob Garrison 2018-01-30 17:45:23 -06:00
parent 18410a3888
commit 25eb3f1856
2 changed files with 10 additions and 9 deletions

View File

@ -816,6 +816,7 @@ $.extend($.tablesorter.language, {
<h3>Notes</h3>
<ul>
<li><span class="label label-info">Info</span> These changes still require the user to enter spaces in the filter to perform the search, e.g. <code>1 à 10</code> (shows rows with numbers between 1 and 10).</li>
<li><span class="label label-info">Info</span> Extra spaces around the value will be trimmed and it is valid to set a value to an empty string; but this won't disable the filter type (use `-` for "to", `|` for "or" and "&&" for "and").</li>
<li>
<span class="label warning">Warning</span> These language values are added to a regular expression using <code>new RegExp()</code>:
<ul>

View File

@ -368,8 +368,8 @@
var options, string, txt, $header, column, val, fxn, noSelect,
c = table.config,
wo = c.widgetOptions,
escRegExp = function(prefix, str, suffix) {
str = str.trim().replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
processStr = function(prefix, str, suffix) {
str = str.trim();
// don't include prefix/suffix if str is empty
return str === '' ? '' : (prefix || '') + str + (suffix || '');
};
@ -388,13 +388,13 @@
$.extend( tsfRegex, {
child : new RegExp( c.cssChildRow ),
filtered : new RegExp( wo.filter_filteredRow ),
alreadyFiltered : new RegExp( '(\\s+(-' + escRegExp('|', ts.language.or) + escRegExp('|', ts.language.to) + ')\\s+)', 'i' ),
toTest : new RegExp( '\\s+(-' + escRegExp('|', ts.language.to) + ')\\s+', 'i' ),
toSplit : new RegExp( '(?:\\s+(?:-' + escRegExp('|', ts.language.to) + ')\\s+)', 'gi' ),
andTest : new RegExp( '\\s+(' + escRegExp('', ts.language.and, '|') + '&&)\\s+', 'i' ),
andSplit : new RegExp( '(?:\\s+(?:' + escRegExp('', ts.language.and, '|') + '&&)\\s+)', 'gi' ),
orTest : new RegExp( '(\\|' + escRegExp('|\\s+', ts.language.or, '\\s+') + ')', 'i' ),
orSplit : new RegExp( '(?:\\|' + escRegExp('|\\s+(?:', ts.language.or, ')\\s+') + ')', 'gi' ),
alreadyFiltered : new RegExp( '(\\s+(-' + processStr('|', ts.language.or) + processStr('|', ts.language.to) + ')\\s+)', 'i' ),
toTest : new RegExp( '\\s+(-' + processStr('|', ts.language.to) + ')\\s+', 'i' ),
toSplit : new RegExp( '(?:\\s+(?:-' + processStr('|', ts.language.to) + ')\\s+)', 'gi' ),
andTest : new RegExp( '\\s+(' + processStr('', ts.language.and, '|') + '&&)\\s+', 'i' ),
andSplit : new RegExp( '(?:\\s+(?:' + processStr('', ts.language.and, '|') + '&&)\\s+)', 'gi' ),
orTest : new RegExp( '(\\|' + processStr('|\\s+', ts.language.or, '\\s+') + ')', 'i' ),
orSplit : new RegExp( '(?:\\|' + processStr('|\\s+(?:', ts.language.or, ')\\s+') + ')', 'gi' ),
iQuery : new RegExp( val, 'i' ),
igQuery : new RegExp( val, 'ig' ),
operTest : /^[<>]=?/,