fix(cli): allow blob frames and objects in web UI CSP (#60453)

This commit is contained in:
Luke Parker
2026-10-30 14:06:15 +10:00
committed by GitHub
Unverified
parent 0bf67d5401
commit 57c7b70d2e
2 changed files with 5 additions and 1 deletions
+3 -1
View File
@@ -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) {
+2
View File
@@ -217,6 +217,8 @@ describe("web UI", () => {
expect(fallback.headers.get("content-security-policy")).toContain("default-src 'self'")
expect(fallback.headers.get("content-security-policy")).toContain("connect-src * data: blob:")
expect(fallback.headers.get("content-security-policy")).toContain("worker-src 'self' blob:")
expect(fallback.headers.get("content-security-policy")).toContain("frame-src 'self' blob:")
expect(fallback.headers.get("content-security-policy")).toContain("object-src 'self' blob:")
const dotted = yield* Effect.promise(() => fetch(`${origin}/workspace/example.js`))
expect(dotted.status).toBe(200)