fix(editor): Avoid sanitizing output to search node data (#8126)

## Summary
In search feature, output sanitization was added to support `<mark` tag
in output panel to highlight searched text. This removes any html like
data in the input/output panel..
This PR removes sanitization while keeping text highlights..


## Related tickets and issues
https://community.n8n.io/t/n8n-output/33997
https://community.n8n.io/t/html-tags-in-editor-rendered/34240
https://github.com/n8n-io/n8n/issues/8081
https://linear.app/n8n/issue/ADO-1594/node-output-view-not-consistent
https://linear.app/n8n/issue/ADO-1597/bug-xml-display-issue


## Review / Merge checklist
- [X] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.
This commit is contained in:
Mutasem Aldmour
2023-12-22 15:03:40 +01:00
committed by GitHub
parent e928210ccd
commit c83d9f45ba
9 changed files with 279 additions and 75 deletions

View File

@@ -52,7 +52,10 @@
[$style.draggingHeader]: isDragging,
}"
>
<span v-html="highlightSearchTerm(column || '')" />
<TextWithHighlights
:content="getValueToRender(column || '')"
:search="search"
/>
<div :class="$style.dragButton">
<font-awesome-icon icon="grip-vertical" />
</div>
@@ -117,10 +120,11 @@
@mouseleave="onMouseLeaveCell"
:class="hasJsonInColumn(index2) ? $style.minColWidth : $style.limitColWidth"
>
<span
<TextWithHighlights
v-if="isSimple(data)"
:content="getValueToRender(data)"
:search="search"
:class="{ [$style.value]: true, [$style.empty]: isEmpty(data) }"
v-html="highlightSearchTerm(data)"
/>
<n8n-tree :nodeClass="$style.nodeClass" v-else :value="data">
<template #label="{ label, path }">
@@ -141,9 +145,10 @@
>
</template>
<template #value="{ value }">
<span
<TextWithHighlights
:content="getValueToRender(value)"
:search="search"
:class="{ [$style.nestedValue]: true, [$style.empty]: isEmpty(value) }"
v-html="highlightSearchTerm(value)"
/>
</template>
</n8n-tree>
@@ -162,7 +167,6 @@ import type { PropType } from 'vue';
import { mapStores } from 'pinia';
import type { INodeUi, ITableData, NDVState } from '@/Interface';
import { shorten } from '@/utils/typesUtils';
import { highlightText, sanitizeHtml } from '@/utils/htmlUtils';
import { getPairedItemId } from '@/utils/pairedItemUtils';
import type { GenericValue, IDataObject, INodeExecutionData } from 'n8n-workflow';
import Draggable from './Draggable.vue';
@@ -171,6 +175,7 @@ import { useNDVStore } from '@/stores/ndv.store';
import MappingPill from './MappingPill.vue';
import { getMappedExpression } from '@/utils/mappingUtils';
import { useExternalHooks } from '@/composables/useExternalHooks';
import TextWithHighlights from './TextWithHighlights.vue';
const MAX_COLUMNS_LIMIT = 40;
@@ -178,7 +183,7 @@ type DraggableRef = InstanceType<typeof Draggable>;
export default defineComponent({
name: 'run-data-table',
components: { Draggable, MappingPill },
components: { Draggable, MappingPill, TextWithHighlights },
props: {
node: {
type: Object as PropType<INodeUi>,
@@ -392,9 +397,6 @@ export default defineComponent({
}
return value;
},
highlightSearchTerm(value: string): string {
return sanitizeHtml(highlightText(this.getValueToRender(value), this.search));
},
onDragStart() {
this.draggedColumn = true;
this.ndvStore.resetMappingTelemetry();