Skip to content

Commit 0ce3722

Browse files
authored
Merge pull request MoveInc#13 from kraftman/regex-fixes
Escape regex characters before parsing them
2 parents 1afa49c + a5148c9 commit 0ce3722

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

demo/index.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
<tr>
275275
<td>20</td>
276276
<td>01</td>
277-
<td>nulla.magna.malesuada@musProin.edu</td>
277+
<td>[nulla.magna.malesuada@musProin.edu</td>
278278
<td>30.01.17</td>
279279
<td>Ac Urna Corp.</td>
280280
<td>2</td>

dist/jquery.bootgrid.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* jQuery Bootgrid v1.4.2 - 08/02/2017
3-
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
2+
* jQuery Bootgrid v1.4.2 - 05/24/2018
3+
* Copyright (c) 2014-2018 Rafael Staib (http://www.jquery-bootgrid.com)
44
* Licensed under MIT http://www.opensource.org/licenses/MIT
55
*/
66
.bootgrid-header,

dist/jquery.bootgrid.fa.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* jQuery Bootgrid v1.4.2 - 08/02/2017
3-
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
2+
* jQuery Bootgrid v1.4.2 - 05/24/2018
3+
* Copyright (c) 2014-2018 Rafael Staib (http://www.jquery-bootgrid.com)
44
* Licensed under MIT http://www.opensource.org/licenses/MIT
55
*/
66
;(function ($, window, undefined)

dist/jquery.bootgrid.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*!
2-
* jQuery Bootgrid v1.4.2 - 08/02/2017
3-
* Copyright (c) 2014-2017 Rafael Staib (http://www.jquery-bootgrid.com)
2+
* jQuery Bootgrid v1.4.2 - 05/24/2018
3+
* Copyright (c) 2014-2018 Rafael Staib (http://www.jquery-bootgrid.com)
44
* Licensed under MIT http://www.opensource.org/licenses/MIT
55
*/
66
;(function ($, window, undefined)
@@ -87,11 +87,15 @@ function highlightAppendedRows(rows) {
8787
}
8888
}
8989

90+
function escapeRegExp(str) {
91+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
92+
}
93+
9094
// Replaces all occurrences of the word in the given html
9195
// Original source: http://stackoverflow.com/questions/8503121/replace-words-in-a-string-but-ignore-html
9296
function highlightResults(html) {
9397
var that = this,
94-
word = that.searchPhrase,
98+
word = escapeRegExp(that.searchPhrase),
9599
tpl = this.options.templates,
96100
css = this.options.css,
97101
container = document.createElement("div"),
@@ -189,16 +193,17 @@ response = {
189193
}
190194
*/
191195

196+
197+
192198
function loadData() {
193199
var that = this;
194200

195201
this.element._bgBusyAria(true).trigger("load" + namespace);
196202
showLoading.call(this);
197203

198204
function containsPhrase(row) {
199-
var column,
200-
searchPattern = new RegExp(that.searchPhrase, (that.options.caseSensitive) ? "g" : "gi");
201-
205+
var column;
206+
var searchPattern = new RegExp(escapeRegExp(that.searchPhrase), (that.options.caseSensitive) ? "g" : "gi");
202207
for (var i = 0; i < that.columns.length; i++) {
203208
column = that.columns[i];
204209
if (column.searchable && (column.visible || that.options.searchSettings.includeHidden) &&

0 commit comments

Comments
 (0)