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

Adopt VS Code's 'asWebviewUri' API #1027

Closed
mjbvz opened this issue May 16, 2020 · 6 comments
Closed

Adopt VS Code's 'asWebviewUri' API #1027

mjbvz opened this issue May 16, 2020 · 6 comments
Assignees

Comments

@mjbvz
Copy link
Contributor

mjbvz commented May 16, 2020

Hi, I maintain VS Code's Webview API

Issue

Our telemetry suggests that your extension uses webviews and may be loading resources in these webviews using hardcoded vscode-resource: URIs. These URIs have some important limitations and don't work properly when VS Code is run in a browser. We are also making changes in the desktop version of VS Code that may cause these URIs to not work properly in future versions of VS Code.

While we are making our best effort to continue support existing webview extensions that use vscode-resource: URIs on desktop versions of VS Code, we will not able to fully support all uses cases.

Fix

To ensure that your extension continues to work in as many environments as possible—including on web and remotely—please:

These APIs shipped around 2 years ago so they should be available in all modern versions of VS Code. You can find additional information about the issue here: microsoft/vscode#97962

Let me know if you have any questions about this change

@rchiodo
Copy link
Contributor

rchiodo commented May 18, 2020

@mjbvz is this just a general ask or did you have a specific reason to ask us to do this? We should already be using asWebviewUri everywhere.

Perhaps there's somewhere not so obvious when looking at our code but you have some logging to indicate we are not using asWebviewUri?

@rchiodo
Copy link
Contributor

rchiodo commented May 18, 2020

The only place vscode-resource is mentioned in the code should be in our cspSource declaration.

See here:
https://github.com/microsoft/vscode-python/blob/5d13fa2bd948fd0949d5a12c571045bf698f7253/src/client/common/application/webPanels/webPanel.ts#L166

@mjbvz
Copy link
Contributor Author

mjbvz commented May 18, 2020

Our telemetry showed the python extension was webview-resource somewhere. You'll need to update the csp as describe to use Webview.cspSource

@rchiodo rchiodo self-assigned this May 29, 2020
@IanMatthewHuff
Copy link
Member

@rchiodo I still see a vscode-resource: in two csps. But it looks like it's in webPanel.ts and webPanelServer.ts and in webPanel.ts it's only in the path for generateServerReactHTML. That path was just for the web server idea that we abandoned? Maybe we should pull that code out at this point. I can open an issue if needed for that.

@IanMatthewHuff IanMatthewHuff self-assigned this Jun 3, 2020
@rchiodo
Copy link
Contributor

rchiodo commented Jun 3, 2020

Yeah it's not in any code the runs for a user. WebPanelServer can't use cspSource because it doesn't create a webview. But the server react code can (or should be removed).

@IanMatthewHuff
Copy link
Member

Created microsoft/vscode-python#12140 for removing the old code. And validating this one.

@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 11, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants