Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Registering components causes CSP style-src errors #545

Open
dotNomad opened this issue Mar 28, 2024 · 1 comment
Open

Registering components causes CSP style-src errors #545

dotNomad opened this issue Mar 28, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@dotNomad
Copy link

dotNomad commented Mar 28, 2024

Describe the bug

Registering a component in vscode-webview-ui-toolkit causes a Content Security Policy error in the extension webview registering it.

To reproduce

To reproduce the default vscode-webview-ui-toolkit hello world example causes the same problem.

Removing the provideVSCodeDesignSystem().register(vsCodeButton()); line removes the Content Security Policy, inline style error.

Note: Using the react imports like the hello-world-react-vite example does not cause the same error. This is unique to the React imports however, the [hello-world-vue](https://github.com/microsoft/vscode-webview-ui-toolkit-samples/tree/main/frameworks/hello-world-vue example) does get the error.

Expected behavior

I would expect that utilizing the components in vscode-webview-ui-toolkit does not cause Content Security Policy directive errors in VSCode extension webviews. Additionally inline styles should be applied where expected.

Current behavior

Opening a webview that registers a toolkit component causes the following error in the developer tools console:

webview.js:2829 Refused to apply inline style because it violates the following Content Security Policy directive: "default-src 'none'". Either the 'unsafe-inline' keyword, a hash ('sha256-47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU='), or a nonce ('nonce-...') is required to enable inline execution. Note also that 'style-src' was not explicitly set, so 'default-src' is used as a fallback.

Screenshots

CleanShot 2024-03-28 at 16 29 54@2x

Desktop:

  • OS Version: macOS 14.4.1
  • Toolkit Version: v1.4.0
@dotNomad dotNomad added the bug Something isn't working label Mar 28, 2024
@quanzhuo
Copy link

any update?

I met the save error. with "@vscode/webview-ui-toolkit": "^1.4.0"

I use this ui toolkit with pure html, css, javascript

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants