2
0
mirror of https://github.com/devbridge/jQuery-Autocomplete.git synced 2024-11-25 06:07:45 +00:00

Merge pull request #336 from SunboX/fix-html-entities

Fix html entities
This commit is contained in:
Tomas Kirda 2015-03-24 10:41:50 -05:00
commit 08c284c00d
2 changed files with 14 additions and 2 deletions

View File

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

View File

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