feat: sanitize html before assiging it to tempDiv (#13252)

This commit is contained in:
Shivam Mishra
2026-01-12 22:41:37 +05:30
committed by GitHub
parent 8311657f9c
commit 58cec84b93
4 changed files with 80 additions and 3 deletions

View File

@@ -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 || '';
};