Kaynağa Gözat

fix(dashboard): Improve security of html sanitization

Michael Bromley 2 ay önce
ebeveyn
işleme
4fb3bb03af

+ 4 - 4
packages/dashboard/src/lib/components/shared/table-cell/order-table-cell-components.tsx

@@ -47,10 +47,10 @@ export const RichTextDescriptionCell: DataTableCellComponent<{ description: stri
 
 
     // Strip HTML tags and decode HTML entities
     // Strip HTML tags and decode HTML entities
     const textContent = useMemo(() => {
     const textContent = useMemo(() => {
-        const stripped = value?.replace(/<[^>]*>/g, '') || '';
-        const textArea = document.createElement('textarea');
-        textArea.innerHTML = stripped;
-        return textArea.value;
+        if (!value) return '';
+        const div = document.createElement('div');
+        div.innerHTML = value;
+        return div.textContent ?? '';
     }, [value]);
     }, [value]);
 
 
     const shortLength = 100;
     const shortLength = 100;