fix: video not rendering — add TipTap Video extension, allow HTTP src

TipTap didn't recognize <video> tags without a custom node extension,
serializing them as escaped text. Also revert video src to allow HTTP
since request.base_url returns http:// behind reverse proxy.
This commit is contained in:
Fringg
2026-03-23 12:11:51 +03:00
parent 74080004e8
commit 25f3602aea
3 changed files with 39 additions and 6 deletions

View File

@@ -189,13 +189,14 @@ function sanitizeHtml(html: string): string {
}
});
// Hook: validate <video> src — HTTPS only
// Hook: validate <video> src — only allow http/https (block javascript:, data:, etc.)
// HTTP is permitted because request.base_url behind a reverse proxy returns http://
DOMPurify.addHook('afterSanitizeAttributes', (node) => {
if (node.tagName === 'VIDEO') {
const src = node.getAttribute('src') ?? '';
try {
const url = new URL(src);
if (url.protocol !== 'https:') {
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
node.remove();
return;
}