2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-29 08:14:06 +00:00

Fix issue of highlighting string when it contains html specific characters, fixes #385

This commit is contained in:
Tomas Kirda 2015-07-29 15:51:36 +03:00
parent 9d06ec6f19
commit 3328147b93

View File

@ -127,15 +127,15 @@
$.Autocomplete = Autocomplete; $.Autocomplete = Autocomplete;
Autocomplete.formatResult = function (suggestion, currentValue) { Autocomplete.formatResult = function (suggestion, currentValue) {
var htmlSafeString = suggestion.value var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
return suggestion.value
.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')
.replace(/&/g, '&amp;') .replace(/&/g, '&amp;')
.replace(/</g, '&lt;') .replace(/</g, '&lt;')
.replace(/>/g, '&gt;') .replace(/>/g, '&gt;')
.replace(/"/g, '&quot;'); .replace(/"/g, '&quot;')
.replace(/&lt;(\/?strong)&gt;/g, '<$1>');
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
return htmlSafeString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
}; };
Autocomplete.prototype = { Autocomplete.prototype = {