Skip to content

Commit 537cd80

Browse files
committed
fix: add file+.vscode-resource.vscode-cdn.net to CSP for portable VS Code support
- Added file+.vscode-resource.vscode-cdn.net protocol to connect-src and media-src directives - This fixes audio playback and API requests in portable VS Code environments - Updated tests to verify the CSP includes the necessary protocols Fixes #5949
1 parent cc369da commit 537cd80

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/core/webview/ClineProvider.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,9 @@ export class ClineProvider
679679
`font-src ${webview.cspSource} data:`,
680680
`style-src ${webview.cspSource} 'unsafe-inline' https://* http://${localServerUrl} http://0.0.0.0:${localPort}`,
681681
`img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:`,
682-
`media-src ${webview.cspSource}`,
682+
`media-src ${webview.cspSource} file+.vscode-resource.vscode-cdn.net:`,
683683
`script-src 'unsafe-eval' ${webview.cspSource} https://* https://*.posthog.com http://${localServerUrl} http://0.0.0.0:${localPort} 'nonce-${nonce}'`,
684-
`connect-src https://* https://*.posthog.com ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort}`,
684+
`connect-src https://* https://*.posthog.com ws://${localServerUrl} ws://0.0.0.0:${localPort} http://${localServerUrl} http://0.0.0.0:${localPort} file+.vscode-resource.vscode-cdn.net:`,
685685
]
686686

687687
return /*html*/ `
@@ -763,7 +763,7 @@ export class ClineProvider
763763
<meta charset="utf-8">
764764
<meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no">
765765
<meta name="theme-color" content="#000000">
766-
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource}; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://us-assets.i.posthog.com 'strict-dynamic'; connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com;">
766+
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; font-src ${webview.cspSource} data:; style-src ${webview.cspSource} 'unsafe-inline'; img-src ${webview.cspSource} https://storage.googleapis.com https://img.clerk.com data:; media-src ${webview.cspSource} file+.vscode-resource.vscode-cdn.net:; script-src ${webview.cspSource} 'wasm-unsafe-eval' 'nonce-${nonce}' https://us-assets.i.posthog.com 'strict-dynamic'; connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com file+.vscode-resource.vscode-cdn.net:;">
767767
<link rel="stylesheet" type="text/css" href="${stylesUri}">
768768
<link href="${codiconsUri}" rel="stylesheet" />
769769
<script nonce="${nonce}">

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,10 +471,13 @@ describe("ClineProvider", () => {
471471

472472
expect(mockWebviewView.webview.html).toContain("<!DOCTYPE html>")
473473

474-
// Verify Content Security Policy contains the necessary PostHog domains
474+
// Verify Content Security Policy contains the necessary PostHog domains and file protocol
475475
expect(mockWebviewView.webview.html).toContain(
476-
"connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com",
476+
"connect-src https://openrouter.ai https://api.requesty.ai https://us.i.posthog.com https://us-assets.i.posthog.com file+.vscode-resource.vscode-cdn.net:",
477477
)
478+
// Verify media-src includes file protocol for audio files
479+
expect(mockWebviewView.webview.html).toContain("media-src")
480+
expect(mockWebviewView.webview.html).toContain("file+.vscode-resource.vscode-cdn.net:")
478481

479482
// Extract the script-src directive section and verify required security elements
480483
const html = mockWebviewView.webview.html

0 commit comments

Comments
 (0)