Office preview WebView may break under strict Content-Security-Policy #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The app renders Office document previews (Word, Excel, etc.) inside a
WebView(ImagePreviewDialog.kt, around line 620). The server recently addedContent-Security-Policyheaders to all responses. If the CSP on the Office preview endpoint (/api/v1/files/{id}/office) is strict enough to block inline scripts or restrictscript-src, the WebView will silently fail to render the document — no crash, just a blank or broken preview.Affected component
app/src/main/java/com/dumango/filecloud/ui/components/ImagePreviewDialog.ktAuthenticatedWebViewinner class (approx. lines 581–650)settings.javaScriptEnabled = true+settings.domStorageEnabled = trueare setAuthorizationheader but does not inspect or relax CSP headersExpected behaviour
Suggested fixes
/office) serves a CSP that is compatible with WebView rendering (allow the scripts required by the preview renderer).onPageFinished/onReceivedErrorcallbacks to detect blank/failed loads and display a fallback UI.WebViewClient.onReceivedHttpErrorto catch CSP-blocked responses (HTTP 200 with no content) and show the fallback.Context
Discovered during compatibility audit against server security-hardening branch (
security-hardening-2026-04). No crash — purely a silent rendering failure risk.