aboutsummaryrefslogtreecommitdiffstats
path: root/themes/default
diff options
context:
space:
mode:
authormistic100 <mistic@piwigo.org>2013-06-15 13:50:10 +0000
committermistic100 <mistic@piwigo.org>2013-06-15 13:50:10 +0000
commit212d37a36acc12b22d6947afe24dbd6e3124e285 (patch)
treed898f6ad5c9acfcf4b002443e4e452a3c3e0b035 /themes/default
parentc3574ce9d50b2833953ba1ef38fdcf3bbcf0e3d9 (diff)
escape special chars used in regex
https://github.com/MartinKoerner/jquery-tokeninput/commit/cc8eab541ad1371c6f0c6730c0154908eb105f5d git-svn-id: http://piwigo.org/svn/trunk@23229 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'themes/default')
-rw-r--r--themes/default/js/plugins/jquery.tokeninput.js7
1 files changed, 6 insertions, 1 deletions
diff --git a/themes/default/js/plugins/jquery.tokeninput.js b/themes/default/js/plugins/jquery.tokeninput.js
index 0c8662b3b..c36a864f2 100644
--- a/themes/default/js/plugins/jquery.tokeninput.js
+++ b/themes/default/js/plugins/jquery.tokeninput.js
@@ -576,7 +576,12 @@ $.TokenList = function (input, url_or_data, settings) {
// Highlight the query part of the search term
function highlight_term(value, term) {
- return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
+ return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + escape_regexp_chars(term) + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<b>$1</b>");
+ }
+
+ function escape_regexp_chars(string) {
+ var specials = new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"); // .*+?|()[]{}\
+ return string.replace(specials, "\\$&");
}
// Populate the results dropdown with some results