Skip to content

Commit

Permalink
apply escape regex in exFilterColumn multi select
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmack committed Aug 30, 2016
1 parent a58be6b commit 239f7b7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
1 change: 1 addition & 0 deletions ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Fixed values with quotation marks filtered incorrectly by filter_type select https://github.com/vedmack/yadcf/issues/317
* Added moment_date_format for better parsing when using datepicker_type: 'bootstrap-datetimepicker'
* Some of additional closed issues https://github.com/vedmack/yadcf/issues/295 / https://github.com/vedmack/yadcf/issues/308 / https://github.com/vedmack/yadcf/issues/314
https://github.com/vedmack/yadcf/issues/342 /



Expand Down
13 changes: 12 additions & 1 deletion jquery.dataTables.yadcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Yet Another DataTables Column Filter - (yadcf)
*
* File: jquery.dataTables.yadcf.js
* Version: 0.9.0.beta.25 (grab latest stable from https://github.com/vedmack/yadcf/releases)
* Version: 0.9.0.beta.26 (grab latest stable from https://github.com/vedmack/yadcf/releases)
*
* Author: Daniel Reznick
* Info: https://github.com/vedmack/yadcf
Expand Down Expand Up @@ -637,6 +637,14 @@ var yadcf = (function ($) {
function escapeRegExp(string) {
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}

function escapeRegExpInArray(arr) {
var i;
for (i = 0; i < arr.length; i++) {
arr[i] = arr[i].replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
return arr
}

function replaceAll(string, find, replace) {
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
Expand Down Expand Up @@ -752,6 +760,9 @@ var yadcf = (function ($) {
ret_val = "^((?!" + selected_value + ").)*$";
}
} else {
if (filter_match_mode !== 'regex') {
selected_value = escapeRegExpInArray(selected_value);
}
if (filter_match_mode === "contains") {
ret_val = selected_value.join("|");
} else if (filter_match_mode === "exact") {
Expand Down

0 comments on commit 239f7b7

Please sign in to comment.