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

@@ -33,7 +33,9 @@
@update:selectedValue="selectedJsonPath = $event"
>
<template #renderNodeKey="{ node }">
<span
<TextWithHighlights
:content="getContent(node.key)"
:search="search"
data-target="mappable"
:data-value="getJsonParameterPath(node.path)"
:data-name="node.key"
@@ -43,13 +45,18 @@
[$style.mappable]: mappingEnabled,
[$style.dragged]: draggingPath === node.path,
}"
v-html="highlightSearchTerm(node.key)"
/>
</template>
<template #renderNodeValue="{ node }">
<span v-if="isNaN(node.index)" v-html="highlightSearchTerm(node.content)" />
<span
<TextWithHighlights
v-if="isNaN(node.index)"
:content="getContent(node.content)"
:search="search"
/>
<TextWithHighlights
v-else
:content="getContent(node.content)"
:search="search"
data-target="mappable"
:data-value="getJsonParameterPath(node.path)"
:data-name="getListItemName(node.path)"
@@ -60,7 +67,6 @@
[$style.dragged]: draggingPath === node.path,
}"
class="ph-no-capture"
v-html="highlightSearchTerm(node.content)"
/>
</template>
</vue-json-pretty>
@@ -76,7 +82,6 @@ import type { IDataObject, INodeExecutionData } from 'n8n-workflow';
import Draggable from '@/components/Draggable.vue';
import { executionDataToJson } from '@/utils/nodeTypesUtils';
import { isString } from '@/utils/typeGuards';
import { highlightText, sanitizeHtml } from '@/utils/htmlUtils';
import { shorten } from '@/utils/typesUtils';
import type { INodeUi } from '@/Interface';
import { mapStores } from 'pinia';
@@ -86,6 +91,7 @@ import { getMappedExpression } from '@/utils/mappingUtils';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { nonExistingJsonPath } from '@/constants';
import { useExternalHooks } from '@/composables/useExternalHooks';
import TextWithHighlights from './TextWithHighlights.vue';
const RunDataJsonActions = defineAsyncComponent(
async () => import('@/components/RunDataJsonActions.vue'),
@@ -98,6 +104,7 @@ export default defineComponent({
Draggable,
RunDataJsonActions,
MappingPill,
TextWithHighlights,
},
props: {
editMode: {
@@ -202,9 +209,6 @@ export default defineComponent({
getListItemName(path: string): string {
return path.replace(/^(\["?\d"?]\.?)/g, '');
},
highlightSearchTerm(value: string): string {
return sanitizeHtml(highlightText(this.getContent(value), this.search));
},
},
});
</script>