mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 06:34:05 -08:00
fix(editor): Fix Show details
summary (#6113)
* 🐛 Fix `Show details` summary * 🚚 Move constants out of sanitizer
This commit is contained in:
parent
a72a5112f3
commit
90a62ccfb5
|
@ -532,3 +532,19 @@ export const TEMPLATE_EXPERIMENT = {
|
||||||
export const EXPERIMENTS_TO_TRACK = [TEMPLATE_EXPERIMENT.name, AUTO_INSERT_ACTION_EXPERIMENT.name];
|
export const EXPERIMENTS_TO_TRACK = [TEMPLATE_EXPERIMENT.name, AUTO_INSERT_ACTION_EXPERIMENT.name];
|
||||||
|
|
||||||
export const NODE_TYPES_EXCLUDED_FROM_OUTPUT_NAME_APPEND = [FILTER_NODE_TYPE];
|
export const NODE_TYPES_EXCLUDED_FROM_OUTPUT_NAME_APPEND = [FILTER_NODE_TYPE];
|
||||||
|
|
||||||
|
export const ALLOWED_HTML_ATTRIBUTES = ['href', 'name', 'target', 'title', 'class', 'id', 'style'];
|
||||||
|
|
||||||
|
export const ALLOWED_HTML_TAGS = [
|
||||||
|
'p',
|
||||||
|
'strong',
|
||||||
|
'b',
|
||||||
|
'code',
|
||||||
|
'a',
|
||||||
|
'br',
|
||||||
|
'i',
|
||||||
|
'em',
|
||||||
|
'small',
|
||||||
|
'details',
|
||||||
|
'summary',
|
||||||
|
];
|
||||||
|
|
|
@ -1,13 +1,11 @@
|
||||||
import xss, { friendlyAttrValue } from 'xss';
|
import xss, { friendlyAttrValue } from 'xss';
|
||||||
|
import { ALLOWED_HTML_ATTRIBUTES, ALLOWED_HTML_TAGS } from '@/constants';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Constants and utility functions that help in HTML, CSS and DOM manipulation
|
Constants and utility functions that help in HTML, CSS and DOM manipulation
|
||||||
*/
|
*/
|
||||||
|
|
||||||
export function sanitizeHtml(dirtyHtml: string) {
|
export function sanitizeHtml(dirtyHtml: string) {
|
||||||
const allowedAttributes = ['href', 'name', 'target', 'title', 'class', 'id'];
|
|
||||||
const allowedTags = ['p', 'strong', 'b', 'code', 'a', 'br', 'i', 'em', 'small'];
|
|
||||||
|
|
||||||
const sanitizedHtml = xss(dirtyHtml, {
|
const sanitizedHtml = xss(dirtyHtml, {
|
||||||
onTagAttr: (tag, name, value) => {
|
onTagAttr: (tag, name, value) => {
|
||||||
if (tag === 'img' && name === 'src') {
|
if (tag === 'img' && name === 'src') {
|
||||||
|
@ -19,8 +17,7 @@ export function sanitizeHtml(dirtyHtml: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allow `allowedAttributes` and all `data-*` attributes
|
if (ALLOWED_HTML_ATTRIBUTES.includes(name) || name.startsWith('data-')) {
|
||||||
if (allowedAttributes.includes(name) || name.startsWith('data-')) {
|
|
||||||
return `${name}="${friendlyAttrValue(value)}"`;
|
return `${name}="${friendlyAttrValue(value)}"`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +25,7 @@ export function sanitizeHtml(dirtyHtml: string) {
|
||||||
// Return nothing, means keep the default handling measure
|
// Return nothing, means keep the default handling measure
|
||||||
},
|
},
|
||||||
onTag: (tag) => {
|
onTag: (tag) => {
|
||||||
if (!allowedTags.includes(tag)) return '';
|
if (!ALLOWED_HTML_TAGS.includes(tag)) return '';
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue