diff options
author | Jacob Thornton <jacobthornton@gmail.com> | 2012-03-20 02:33:28 +0400 |
---|---|---|
committer | Jacob Thornton <jacobthornton@gmail.com> | 2012-03-20 02:33:28 +0400 |
commit | 83a7a698939b5b4cba3c04a86befc12b9005df3d (patch) | |
tree | b2251b8f03b1de86970ba66be05f63b572cc5118 /js/bootstrap-typeahead.js | |
parent | bf59220b87a3b5960381f500dbc6a310a8aef60b (diff) |
typeahead should escape regexp special chars
Diffstat (limited to 'js/bootstrap-typeahead.js')
-rw-r--r-- | js/bootstrap-typeahead.js | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/js/bootstrap-typeahead.js b/js/bootstrap-typeahead.js index dc2f882218..804e60dc44 100644 --- a/js/bootstrap-typeahead.js +++ b/js/bootstrap-typeahead.js @@ -109,7 +109,8 @@ } , highlighter: function (item) { - return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) { + var query = this.query.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&') + return item.replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) { return '<strong>' + match + '</strong>' }) } |