mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -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: '',
|
default: '',
|
||||||
placeholder: "e.g. We'll get back to you soon",
|
placeholder: "e.g. We'll get back to you soon",
|
||||||
description:
|
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: {
|
typeOptions: {
|
||||||
rows: 2,
|
rows: 2,
|
||||||
},
|
},
|
||||||
|
|
|
@ -24,6 +24,35 @@ import { getResolvables } from '../../utils/utilities';
|
||||||
import { WebhookAuthorizationError } from '../Webhook/error';
|
import { WebhookAuthorizationError } from '../Webhook/error';
|
||||||
import { validateWebhookAuthentication } from '../Webhook/utils';
|
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({
|
export function prepareFormData({
|
||||||
formTitle,
|
formTitle,
|
||||||
formDescription,
|
formDescription,
|
||||||
|
@ -374,13 +403,7 @@ export async function formWebhook(
|
||||||
//Show the form on GET request
|
//Show the form on GET request
|
||||||
if (method === 'GET') {
|
if (method === 'GET') {
|
||||||
const formTitle = context.getNodeParameter('formTitle', '') as string;
|
const formTitle = context.getNodeParameter('formTitle', '') as string;
|
||||||
const formDescription = sanitize(context.getNodeParameter('formDescription', '') as string, {
|
const formDescription = sanitizeHtml(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;
|
const responseMode = context.getNodeParameter('responseMode', '') as string;
|
||||||
|
|
||||||
let formSubmittedText;
|
let formSubmittedText;
|
||||||
|
|
Loading…
Reference in a new issue