mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 19:32:15 +00:00
fix(editor): Fix Show details summary (#6113)
* 🐛 Fix `Show details` summary * 🚚 Move constants out of sanitizer
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
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
|
||||
*/
|
||||
|
||||
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, {
|
||||
onTagAttr: (tag, name, value) => {
|
||||
if (tag === 'img' && name === 'src') {
|
||||
@@ -19,8 +17,7 @@ export function sanitizeHtml(dirtyHtml: string) {
|
||||
}
|
||||
}
|
||||
|
||||
// Allow `allowedAttributes` and all `data-*` attributes
|
||||
if (allowedAttributes.includes(name) || name.startsWith('data-')) {
|
||||
if (ALLOWED_HTML_ATTRIBUTES.includes(name) || name.startsWith('data-')) {
|
||||
return `${name}="${friendlyAttrValue(value)}"`;
|
||||
}
|
||||
|
||||
@@ -28,7 +25,7 @@ export function sanitizeHtml(dirtyHtml: string) {
|
||||
// Return nothing, means keep the default handling measure
|
||||
},
|
||||
onTag: (tag) => {
|
||||
if (!allowedTags.includes(tag)) return '';
|
||||
if (!ALLOWED_HTML_TAGS.includes(tag)) return '';
|
||||
return;
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user