diff --git a/scp/js/bootstrap-typeahead.js b/scp/js/bootstrap-typeahead.js index d53630e4bcaa48f6295c813bb0d6d6bba36131cf..fffa189ecb1875a847f5c174b8fa676016d605bb 100644 --- a/scp/js/bootstrap-typeahead.js +++ b/scp/js/bootstrap-typeahead.js @@ -158,9 +158,8 @@ , highlighter: function (item) { if (!this.query) return item; - return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) { - return '<strong>' + match + '</strong>' - }) + var exp = this.query.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&").replace(' ', '|') + return item.replace(new RegExp(exp, 'ig'), '<strong>$&</strong>') } , render: function (items) { diff --git a/scp/js/scp.js b/scp/js/scp.js index 0b0425e1f8874c93b5abb010412d8e353d36568d..e96cda1b235e1832b53b5e7e9f2fde0927627136 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -256,7 +256,7 @@ var scp_prep = function() { source: function (typeahead, query) { if (last_req) last_req.abort(); var $el = this.$element; - var url = $el.data('url')+'?q='+query; + var url = $el.data('url')+'?q='+encodeURIComponent(query); last_req = $.ajax({ url: url, dataType: 'json',