Skip to content

Commit 3328147

Browse files
author
Tomas Kirda
committed
Fix issue of highlighting string when it contains html specific characters, fixes #385
1 parent 9d06ec6 commit 3328147

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/jquery.autocomplete.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@
127127
$.Autocomplete = Autocomplete;
128128

129129
Autocomplete.formatResult = function (suggestion, currentValue) {
130-
var htmlSafeString = suggestion.value
130+
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
131+
132+
return suggestion.value
133+
.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')
131134
.replace(/&/g, '&amp;')
132135
.replace(/</g, '&lt;')
133136
.replace(/>/g, '&gt;')
134-
.replace(/"/g, '&quot;');
135-
136-
var pattern = '(' + utils.escapeRegExChars(currentValue) + ')';
137-
138-
return htmlSafeString.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>');
137+
.replace(/"/g, '&quot;')
138+
.replace(/&lt;(\/?strong)&gt;/g, '<$1>');
139139
};
140140

141141
Autocomplete.prototype = {

0 commit comments

Comments
 (0)