Skip to content

Commit

Permalink
fix(editor): Fix XSS issue in node error message toast
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi committed Sep 9, 2024
1 parent 13de8af commit 5c7e517
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
18 changes: 18 additions & 0 deletions packages/editor-ui/src/components/NodeExecutionErrorMessage.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script lang="ts" setup>
import { useI18n } from '@/composables/useI18n';
const i18n = useI18n();
defineProps<{
nodeName: string;
errorMessage?: string;
}>();
</script>

<template>
<div>
{{ errorMessage }}<br />
<a data-action="openNodeDetail" :data-action-parameter-node="nodeName">{{
i18n.baseText('node.executionError.openNode')
}}</a>
</div>
</template>
15 changes: 6 additions & 9 deletions packages/editor-ui/src/composables/usePushConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { useNodeTypesStore } from '@/stores/nodeTypes.store';
import { useCredentialsStore } from '@/stores/credentials.store';
import { useSettingsStore } from '@/stores/settings.store';
import { parse } from 'flatted';
import { ref } from 'vue';
import { h, ref } from 'vue';
import { useOrchestrationStore } from '@/stores/orchestration.store';
import { usePushConnectionStore } from '@/stores/pushConnection.store';
import { useExternalHooks } from '@/composables/useExternalHooks';
Expand All @@ -42,6 +42,7 @@ import { useI18n } from '@/composables/useI18n';
import { useTelemetry } from '@/composables/useTelemetry';
import type { PushMessageQueueItem } from '@/types';
import { useAssistantStore } from '@/stores/assistant.store';
import NodeExecutionErrorMessage from '@/components/NodeExecutionErrorMessage.vue';

export function usePushConnection({ router }: { router: ReturnType<typeof useRouter> }) {
const workflowHelpers = useWorkflowHelpers({ router });
Expand Down Expand Up @@ -407,16 +408,12 @@ export function usePushConnection({ router }: { router: ReturnType<typeof useRou

toast.showMessage({
title,
message:
(nodeError?.description ?? runDataExecutedErrorMessage) +
i18n.baseText('pushConnection.executionError.openNode', {
interpolate: {
node: nodeError.node.name,
},
}),
message: h(NodeExecutionErrorMessage, {
errorMessage: nodeError?.description ?? runDataExecutedErrorMessage,
nodeName: nodeError.node.name,
}),
type: 'error',
duration: 0,
dangerouslyUseHTMLString: true,
});
} else {
let title: string;
Expand Down
1 change: 1 addition & 0 deletions packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,7 @@
"node.waitingForYouToCreateAnEventIn": "Waiting for you to create an event in {nodeType}",
"node.discovery.pinData.canvas": "You can pin this output instead of waiting for a test event. Open node to do so.",
"node.discovery.pinData.ndv": "You can pin this output instead of waiting for a test event.",
"node.executionError.openNode": "Open node",
"nodeBase.clickToAddNodeOrDragToConnect": "Click to add node \n or drag to connect",
"nodeCreator.actionsPlaceholderNode.scheduleTrigger": "On a Schedule",
"nodeCreator.actionsPlaceholderNode.webhook": "On a Webhook call",
Expand Down

0 comments on commit 5c7e517

Please sign in to comment.