Skip to content

Commit 0ea8ed5

Browse files
committed
Convert certain characters to their HTML character equivalents
1 parent b813318 commit 0ea8ed5

File tree

1 file changed

+26
-6
lines changed

1 file changed

+26
-6
lines changed

src/LiveSearch.js

+26-6
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ Ext.define('Ext.ux.grid.plugin.LiveSearch', {
66

77
alias: ['plugin.gridlivesearch', 'plugin.livesearch'],
88

9+
uses: [
10+
'Ext.Array',
11+
'Ext.String',
12+
'Ext.Function',
13+
'Ext.util.Format',
14+
'Ext.dom.Element'
15+
],
16+
917
config: {
1018
/**
1119
* @cfg {String} searchValue
@@ -327,9 +335,13 @@ Ext.define('Ext.ux.grid.plugin.LiveSearch', {
327335

328336
if (!cellHTML) return;
329337

330-
cellHTML = cellHTML.replace(me.tagsRe, me.tagsProtect);
338+
if (column.producesHTML) {
339+
cellHTML = cellHTML.replace(me.tagsRe, me.tagsProtect);
340+
} else {
341+
cellHTML = Ext.htmlDecode(cellHTML);
342+
}
331343

332-
if (cell) {
344+
if (cell && column.producesHTML) {
333345
matches = cellHTML.match(me.tagsRe);
334346
}
335347

@@ -345,7 +357,7 @@ Ext.define('Ext.ux.grid.plugin.LiveSearch', {
345357
seen = true;
346358
}
347359

348-
return cell ? '<span class="' + me.matchCls + '">' + m + '</span>' : null;
360+
return cell ? '<span class="' + me.matchCls + '">' + Ext.htmlEncode(m) + '</span>' : null;
349361
});
350362

351363
if (!cell) return;
@@ -355,6 +367,10 @@ Ext.define('Ext.ux.grid.plugin.LiveSearch', {
355367
cellHTML = cellHTML.replace(me.tagsProtect, match);
356368
});
357369

370+
if (!(seen || column.producesHTML)) {
371+
cellHTML = Ext.htmlEncode(cellHTML);
372+
}
373+
358374
// update cell html
359375
cell.innerHTML = cellHTML;
360376
});
@@ -407,12 +423,16 @@ Ext.define('Ext.ux.grid.plugin.LiveSearch', {
407423

408424
if (!cell) return;
409425

410-
matches = cell.innerHTML.match(this.tagsRe);
411-
cellHTML = cell.innerHTML.replace(this.tagsRe, this.tagsProtect);
426+
if (column.producesHTML) {
427+
matches = cell.innerHTML.match(this.tagsRe);
428+
cellHTML = cell.innerHTML.replace(this.tagsRe, this.tagsProtect);
429+
} else {
430+
cellHTML = Ext.htmlDecode(cell.innerHTML);
431+
}
412432

413433
// populate indexes array, set currentIndex, and replace wrap matched string in a span
414434
cellHTML = cellHTML.replace(this.searchRegExp, function(m) {
415-
return '<span class="' + matchCls + '">' + m + '</span>';
435+
return '<span class="' + matchCls + '">' + Ext.htmlEncode(m) + '</span>';
416436
});
417437

418438
// restore protected tags

0 commit comments

Comments
 (0)