fix: add blob: to CSP frame-src and media-src for PDF/video viewing

- frame-src: add 'blob:' (wildcard * only matches network schemes)
- media-src: new directive with 'self' blob: (was falling back to default-src)
- Fixes: PDFs blocked in iframe, videos blocked by media-src fallback
This commit is contained in:
Diocrafts
2026-03-07 18:17:35 +01:00
parent 6b02c10942
commit 03c051f9d8
+5 -3
View File
@@ -413,16 +413,18 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
HeaderName::from_static("content-security-policy"),
// All inline scripts and styles have been migrated to external
// files, so 'unsafe-inline' is no longer needed.
// frame-src is permissive (*) to allow WOPI editor iframes whose
// origin is configured at runtime (Collabora, OnlyOffice, etc.).
// frame-src: '*' only matches network schemes, so 'blob:' must be
// listed explicitly for inline PDF/document viewers.
// media-src: needed for blob: video/audio playback.
HeaderValue::from_static(
"default-src 'self'; \
script-src 'self'; \
style-src 'self'; \
img-src 'self' data: blob:; \
media-src 'self' blob:; \
connect-src 'self'; \
font-src 'self' data:; \
frame-src *; \
frame-src * blob:; \
frame-ancestors 'none'; \
base-uri 'self'; \
form-action 'self'",