feat: sanitize html before assiging it to tempDiv

This commit is contained in:
Shivam Mishra
2026-01-12 22:12:56 +05:30
parent b3a5cc4f88
commit f57485ea50
2 changed files with 22 additions and 1 deletions
@@ -1,4 +1,5 @@
import { format, parseISO, isValid as isValidDate } from 'date-fns';
import DOMPurify from 'dompurify';
/**
* Extracts plain text from HTML content
@@ -13,7 +14,7 @@ export const extractPlainTextFromHtml = html => {
return html.replace(/<[^>]*>/g, ' ');
}
const tempDiv = document.createElement('div');
tempDiv.innerHTML = html;
tempDiv.innerHTML = DOMPurify.sanitize(html);
return tempDiv.textContent || tempDiv.innerText || '';
};