feat(Form Node): Enable HTML in form description

This commit is contained in:
Dana Lee 2025-01-13 16:03:34 +01:00
parent ba14c91255
commit 18516968e8
No known key found for this signature in database
2 changed files with 9 additions and 2 deletions

View file

@ -327,7 +327,7 @@
<form class='card' action='#' method='POST' name='n8n-form' id='n8n-form' novalidate>
<div class='form-header'>
<h1>{{formTitle}}</h1>
<p style="white-space: pre-line">{{formDescription}} </p>
<p style="white-space: pre-line">{{{formDescription}}} </p>
</div>
<div class='inputs-wrapper'>

View file

@ -16,6 +16,7 @@ import {
WAIT_NODE_TYPE,
jsonParse,
} from 'n8n-workflow';
import sanitize from 'sanitize-html';
import type { FormTriggerData, FormTriggerInput } from './interfaces';
import { FORM_TRIGGER_AUTHENTICATION_PROPERTY } from './interfaces';
@ -373,7 +374,13 @@ export async function formWebhook(
//Show the form on GET request
if (method === 'GET') {
const formTitle = context.getNodeParameter('formTitle', '') as string;
const formDescription = context.getNodeParameter('formDescription', '') as string;
const formDescription = sanitize(context.getNodeParameter('formDescription', '') as string, {
allowedTags: ['b', 'i', 'em', 'strong', 'a', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'],
allowedAttributes: {
a: ['href'],
},
nonBooleanAttributes: ['*'],
});
const responseMode = context.getNodeParameter('responseMode', '') as string;
let formSubmittedText;