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

URI encoding problems with vscode.env.openExternal #83610

Closed
RMacfarlane opened this issue Oct 30, 2019 · 4 comments
Closed

URI encoding problems with vscode.env.openExternal #83610

RMacfarlane opened this issue Oct 30, 2019 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority uri verified Verification succeeded
Milestone

Comments

@RMacfarlane
Copy link
Contributor

Issue Type: Bug

Steps:

  1. Download the GitHub Pull Request VSIX, or create an extension with the following and package it:
export async function activate(context: vscode.ExtensionContext) {
	const callbackUri = await vscode.env.createAppUri({ payload: { path: '/did-authenticate' } });
	const uri = vscode.Uri.parse(`https://vscode-auth.github.com/authorize/?callbackUri=${encodeURIComponent(callbackUri.toString())}&responseType=code`);
	vscode.env.openExternal(uri);
}
  1. Start web selfhost using the ./resources/server/web.sh script
  2. Install either extension and reload
  3. Use sign in command if using GHPR extension, or trigger activation of own extension

A dialog appears asking if you would like to open the external url:
Screen Shot 2019-10-29 at 5 20 45 PM

Note here that the callbackUri parameter is only partially uri encoded - the only unencoded & should be before responseType=code. When opened, the link becomes something like https://vscode-auth.github.com/authorize/?callbackUri=http://localhost:9888/callback?vscode-requestId=ddb9fdd5-5cda-48e9-bbdd-62e23f94af2c&vscode-authority=rmacfarlane.test-extension&vscode-path=%2Fdid-authenticate&responseType=code, causing the query params of the callbackUri to be treated as top level query parameters.

VS Code version: Code - Insiders 1.40.0-insider (b7b2184, 2019-10-29T06:46:37.742Z)
OS version: Darwin x64 18.7.0

@RMacfarlane RMacfarlane added the important Issue identified as high-priority label Oct 30, 2019
@jrieken jrieken added this to the October 2019 milestone Oct 30, 2019
@jrieken jrieken added the uri label Oct 30, 2019
@jrieken
Copy link
Member

jrieken commented Oct 30, 2019

Yeah, the idea of the work that went into the uri this month was to make it match the the behaviour of the whatwg-url, e.g the URL global found in browsers et al. So, the behaviour you are seeing is correct but I understand that it's breaking and unwanted - extension are built and tested against our bogus implementation and that's it. I will revert my changes and find a different path forward for fixing unwanted uri behaviour, e.g when opening links et al.

@jrieken jrieken added the bug Issue identified by VS Code Team member as probable bug label Oct 30, 2019
@jrieken
Copy link
Member

jrieken commented Oct 30, 2019

fixed via 58479e8

@jrieken jrieken closed this as completed Oct 30, 2019
@jrieken
Copy link
Member

jrieken commented Oct 30, 2019

trying to go forward with this: #83645

@chakrihacker
Copy link

Facing this issue with vs live share extension, insiders

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug important Issue identified as high-priority uri verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants