diff --git a/script/autocomplete.js b/script/autocomplete.js index 377ad0f..cd6d2dd 100644 --- a/script/autocomplete.js +++ b/script/autocomplete.js @@ -267,6 +267,7 @@ app.filter('highlight', ['$sce', function ($sce) { return function (input, searchParam) { if (typeof input === 'function') return ''; if (searchParam) { + searchParam = escapeSpecialCharacters(searchParam); var words = '(' + searchParam.split(/\ /).join(' |') + '|' + searchParam.split(/\ /).join('|') + @@ -296,3 +297,8 @@ app.directive('suggestion', function(){ } }; }); + +// escape characters that may be interpreted as regex expressions +function escapeSpecialCharacters(string) { + return string.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); +} \ No newline at end of file