Skip to content

Commit

Permalink
use encodeURI on non-encoded uri when 'leaving' vscode, #25852
Browse files Browse the repository at this point in the history
  • Loading branch information
jrieken committed Apr 17, 2019
1 parent 006078a commit 2335966
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/vs/editor/browser/services/openerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class OpenerService implements IOpenerService {

if (equalsIgnoreCase(scheme, Schemas.http) || equalsIgnoreCase(scheme, Schemas.https) || equalsIgnoreCase(scheme, Schemas.mailto)) {
// open http or default mail application
dom.windowOpenNoOpener(resource.toString(true));
dom.windowOpenNoOpener(encodeURI(resource.toString(true)));
return Promise.resolve(true);

} else if (equalsIgnoreCase(scheme, Schemas.command)) {
Expand Down
9 changes: 3 additions & 6 deletions src/vs/workbench/api/browser/mainThreadWindow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,23 +46,20 @@ export class MainThreadWindow implements MainThreadWindowShape {
}

async $openUri(uriComponent: UriComponents, options: IOpenUriOptions): Promise<boolean> {
const uri = URI.revive(uriComponent);
let uri = URI.revive(uriComponent);
if (options.allowTunneling && !!this.environmentService.configuration.remoteAuthority) {
if (uri.scheme === 'http' || uri.scheme === 'https') {
const port = this.getLocalhostPort(uri);
if (typeof port === 'number') {
const tunnel = await this.getOrCreateTunnel(port);
if (tunnel) {
const tunneledUrl = uri.toString().replace(
new RegExp(`^${uri.scheme}://localhost:${port}/`),
`${uri.scheme}://localhost:${tunnel.tunnelLocalPort}/`);
return this.windowsService.openExternal(tunneledUrl);
uri = uri.with({ authority: `localhost:${tunnel.tunnelLocalPort}` });
}
}
}
}

return this.windowsService.openExternal(uri.toString(true));
return this.windowsService.openExternal(encodeURI(uri.toString(true)));
}

private getLocalhostPort(uri: URI): number | undefined {
Expand Down

0 comments on commit 2335966

Please sign in to comment.