mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-19 17:01:37 +03:00
fix(cli): allow blob frames and objects in web UI CSP (#60453)
This commit is contained in:
committed by
GitHub
Unverified
parent
0bf67d5401
commit
57c7b70d2e
@@ -80,8 +80,10 @@ function isRouteNotFound(error: unknown) {
|
||||
|
||||
// qr-scanner decodes in a worker it creates from a blob: URL whenever the browser has no BarcodeDetector (Safari, desktop
|
||||
// Chrome on Windows and Linux). Without worker-src that worker falls under script-src 'self' and never starts.
|
||||
// Artifact previews render HTML and PDF files from blob: URLs; without frame-src and object-src they fall back to
|
||||
// default-src 'self' and are blocked.
|
||||
function csp(hash = "") {
|
||||
return `default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self' data:; media-src 'self' data:; connect-src * data: blob:; worker-src 'self' blob:`
|
||||
return `default-src 'self'; script-src 'self' 'wasm-unsafe-eval'${hash ? ` 'sha256-${hash}'` : ""}; style-src 'self' 'unsafe-inline'; img-src 'self' data: https: blob:; font-src 'self' data:; media-src 'self' data:; connect-src * data: blob:; worker-src 'self' blob:; frame-src 'self' blob:; object-src 'self' blob:`
|
||||
}
|
||||
|
||||
function cspForHtml(body: string) {
|
||||
|
||||
Reference in New Issue
Block a user