Skip to content

Commit

Permalink
fix(editor): Fix potential xss in workflow activation error message
Browse files Browse the repository at this point in the history
  • Loading branch information
tomi committed Sep 9, 2024
1 parent c021381 commit fe4ab74
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<script lang="ts" setup>
import { useI18n } from '@/composables/useI18n';
const i18n = useI18n();
defineProps<{
message: string;
}>();
</script>

<template>
<div>
{{
i18n.baseText(
'workflowActivator.showMessage.displayActivationError.message.errorDataNotUndefined',
)
}}
<br /><i>{{ message }}</i>
</div>
</template>
14 changes: 7 additions & 7 deletions packages/editor-ui/src/components/WorkflowActivator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ import { useToast } from '@/composables/useToast';
import { useWorkflowActivate } from '@/composables/useWorkflowActivate';
import { useWorkflowsStore } from '@/stores/workflows.store';
import { getActivatableTriggerNodes } from '@/utils/nodeTypesUtils';
import { computed } from 'vue';
import type { VNode } from 'vue';
import { computed, h } from 'vue';
import { useI18n } from '@/composables/useI18n';
import type { PermissionsRecord } from '@/permissions';
import { PLACEHOLDER_EMPTY_WORKFLOW_ID } from '@/constants';
import WorkflowActivationErrorMessage from './WorkflowActivationErrorMessage.vue';
const props = defineProps<{
workflowActive: boolean;
Expand Down Expand Up @@ -61,7 +63,7 @@ async function activeChanged(newActiveState: boolean) {
}
async function displayActivationError() {
let errorMessage: string;
let errorMessage: string | VNode;
try {
const errorData = await workflowsStore.getActivationError(props.workflowId);
Expand All @@ -70,10 +72,9 @@ async function displayActivationError() {
'workflowActivator.showMessage.displayActivationError.message.errorDataUndefined',
);
} else {
errorMessage = i18n.baseText(
'workflowActivator.showMessage.displayActivationError.message.errorDataNotUndefined',
{ interpolate: { message: errorData } },
);
errorMessage = h(WorkflowActivationErrorMessage, {
message: errorData,
});
}
} catch (error) {
errorMessage = i18n.baseText(
Expand All @@ -86,7 +87,6 @@ async function displayActivationError() {
message: errorMessage,
type: 'warning',
duration: 0,
dangerouslyUseHTMLString: true,
});
}
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/editor-ui/src/plugins/i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2070,7 +2070,7 @@
"workflowActivator.showMessage.activeChangedWorkflowIdUndefined.message": "Please save it before activating",
"workflowActivator.showMessage.activeChangedWorkflowIdUndefined.title": "Problem activating workflow",
"workflowActivator.showMessage.displayActivationError.message.catchBlock": "Sorry there was a problem requesting the error",
"workflowActivator.showMessage.displayActivationError.message.errorDataNotUndefined": "The following error occurred on workflow activation:<br /><i>{message}</i>",
"workflowActivator.showMessage.displayActivationError.message.errorDataNotUndefined": "The following error occurred on workflow activation:",
"workflowActivator.showMessage.displayActivationError.message.errorDataUndefined": "Unknown error",
"workflowActivator.showMessage.displayActivationError.title": "Problem activating workflow",
"workflowActivator.theWorkflowIsSetToBeActiveBut": "The workflow is activated but could not be started.<br />Click to display error message.",
Expand Down

0 comments on commit fe4ab74

Please sign in to comment.