diff --git a/src/core_plugins/kibana/common/field_formats/types/source.js b/src/core_plugins/kibana/common/field_formats/types/source.js index 81a6eb51eb20d..61509a746c163 100644 --- a/src/core_plugins/kibana/common/field_formats/types/source.js +++ b/src/core_plugins/kibana/common/field_formats/types/source.js @@ -48,7 +48,7 @@ export function createSourceFormat(FieldFormat) { SourceFormat.prototype._convert = { text: (value) => toJson(value), html: function sourceToHtml(source, field, hit) { - if (!field) return this.getConverterFor('text')(source, field, hit); + if (!field) return _.escape(this.getConverterFor('text')(source)); const highlights = (hit && hit.highlight) || {}; const formatted = field.indexPattern.formatHit(hit); diff --git a/src/core_plugins/kibana/public/field_formats/__tests__/_source.js b/src/core_plugins/kibana/public/field_formats/__tests__/_source.js index 09a84ae775430..4726c3993771e 100644 --- a/src/core_plugins/kibana/public/field_formats/__tests__/_source.js +++ b/src/core_plugins/kibana/public/field_formats/__tests__/_source.js @@ -43,8 +43,9 @@ describe('_source formatting', function () { })); it('should use the text content type if a field is not passed', function () { - const hit = _.first(hits); - expect(convertHtml(hit._source)).to.be(`${JSON.stringify(hit._source)}`); + const hit = { 'foo': 'bar', 'number': 42, 'hello': '