mirror of
https://github.com/n8n-io/n8n.git
synced 2025-02-02 07:01:30 -08:00
PR requests and move sanitize HTML to separate function
This commit is contained in:
parent
dd3eac84fa
commit
dff6edf7c3
|
@ -29,7 +29,7 @@ export const formDescription: INodeProperties = {
|
|||
default: '',
|
||||
placeholder: "e.g. We'll get back to you soon",
|
||||
description:
|
||||
'Shown underneath the Form Title. Can be used to prompt the user on how to complete the form.',
|
||||
'Shown underneath the Form Title. Can be used to prompt the user on how to complete the form. Accepts HTML.',
|
||||
typeOptions: {
|
||||
rows: 2,
|
||||
},
|
||||
|
|
|
@ -24,6 +24,35 @@ import { getResolvables } from '../../utils/utilities';
|
|||
import { WebhookAuthorizationError } from '../Webhook/error';
|
||||
import { validateWebhookAuthentication } from '../Webhook/utils';
|
||||
|
||||
function sanitizeHtml(text: string) {
|
||||
return sanitize(text, {
|
||||
allowedTags: [
|
||||
'b',
|
||||
'i',
|
||||
'em',
|
||||
'strong',
|
||||
'a',
|
||||
'h1',
|
||||
'h2',
|
||||
'h3',
|
||||
'h4',
|
||||
'h5',
|
||||
'h6',
|
||||
'u',
|
||||
'sub',
|
||||
'sup',
|
||||
'code',
|
||||
'pre',
|
||||
'span',
|
||||
'br',
|
||||
],
|
||||
allowedAttributes: {
|
||||
a: ['href', 'target', 'rel'],
|
||||
},
|
||||
nonBooleanAttributes: ['*'],
|
||||
});
|
||||
}
|
||||
|
||||
export function prepareFormData({
|
||||
formTitle,
|
||||
formDescription,
|
||||
|
@ -374,13 +403,7 @@ export async function formWebhook(
|
|||
//Show the form on GET request
|
||||
if (method === 'GET') {
|
||||
const formTitle = context.getNodeParameter('formTitle', '') 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 formDescription = sanitizeHtml(context.getNodeParameter('formDescription', '') as string);
|
||||
const responseMode = context.getNodeParameter('responseMode', '') as string;
|
||||
|
||||
let formSubmittedText;
|
||||
|
|
Loading…
Reference in a new issue