Trim whitespace before replacing line breaks in unknown elements

This commit is contained in:
Cohee
2025-05-25 00:52:03 +03:00
parent 8d67874215
commit 34c25300e5

View File

@ -379,7 +379,7 @@ DOMPurify.addHook('uponSanitizeElement', (node, _, config) => {
// Replace line breaks with <br> in unknown elements
if (node instanceof HTMLUnknownElement) {
node.innerHTML = node.innerHTML.replaceAll('\n', '<br>');
node.innerHTML = node.innerHTML.trim().replaceAll('\n', '<br>');
}
const isMediaAllowed = isExternalMediaAllowed();