Fix bug with highlighting in field formatters (#109401)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
cd7f26dd81
commit
4d115dcaa2
|
@ -111,4 +111,18 @@ describe('String Format', () => {
|
|||
'<span class="ffString__emptyValue">(empty)</span>'
|
||||
);
|
||||
});
|
||||
|
||||
test('does escape value while highlighting', () => {
|
||||
const string = new StringFormat();
|
||||
expect(
|
||||
stripSpan(
|
||||
string.convert('<img />', 'html', {
|
||||
field: { name: 'foo' },
|
||||
hit: {
|
||||
highlight: { foo: ['@kibana-highlighted-field@<img />@/kibana-highlighted-field@'] },
|
||||
},
|
||||
})
|
||||
)
|
||||
).toBe('<mark><img /></mark>');
|
||||
});
|
||||
});
|
||||
|
|
|
@ -137,7 +137,7 @@ export class StringFormat extends FieldFormat {
|
|||
}
|
||||
|
||||
return hit?.highlight?.[field?.name]
|
||||
? getHighlightHtml(val, hit.highlight[field.name])
|
||||
? getHighlightHtml(escape(val), hit.highlight[field.name])
|
||||
: escape(this.textConvert(val));
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue