UI fixes & updates

This commit is contained in:
Tim Zöller 2026-01-09 09:05:51 +01:00
parent 22f7f7c271
commit 6a8598ef30
7 changed files with 118 additions and 32 deletions

View file

@ -175,7 +175,7 @@
// Bio
const bioElement = document.getElementById('bio');
if (user.bio) {
bioElement.textContent = user.bio;
bioElement.innerHTML = sanitizeHtml(user.bio);
} else {
bioElement.innerHTML = '<span class="text-muted">No bio yet. <a href="/profile/edit">Add one?</a></span>';
}
@ -290,6 +290,15 @@
div.textContent = text;
return div.innerHTML;
}
function sanitizeHtml(html) {
if (!html) return '';
// Use DOMPurify to sanitize HTML, allowing safe tags like p, br, a
return DOMPurify.sanitize(html, {
ALLOWED_TAGS: ['p', 'br', 'a', 'strong', 'em', 'b', 'i', 'span'],
ALLOWED_ATTR: ['href', 'class', 'rel', 'target']
});
}
});
</script>
</th:block>