Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829

This commit is contained in:
ADS Merger
2020-08-06 07:08:52 +00:00
parent 9c67832880
commit 540046ba00
362 changed files with 7588 additions and 6584 deletions

View File

@@ -99,7 +99,9 @@ function normalizeRequestPath(requestUri: URI) {
//
// vscode-webview-resource://id/scheme//authority?/path
//
const resourceUri = URI.parse(requestUri.path.replace(/^\/([a-z0-9\-]+)(\/{1,2})/i, (_: string, scheme: string, sep: string) => {
// Encode requestUri.path so that URI.parse can properly parse special characters like '#', '?', etc.
const resourceUri = URI.parse(encodeURIComponent(requestUri.path).replace(/%2F/gi, '/').replace(/^\/([a-z0-9\-]+)(\/{1,2})/i, (_: string, scheme: string, sep: string) => {
if (sep.length === 1) {
return `${scheme}:///`; // Add empty authority.
} else {

View File

@@ -27,7 +27,7 @@ export class WebviewPortMappingManager implements IDisposable {
private readonly tunnelService: ITunnelService
) { }
public async getRedirect(resolveAuthority: IAddress, url: string): Promise<string | undefined> {
public async getRedirect(resolveAuthority: IAddress | null | undefined, url: string): Promise<string | undefined> {
const uri = URI.parse(url);
const requestLocalHostInfo = extractLocalHostUriMetaDataForPortMapping(uri);
if (!requestLocalHostInfo) {
@@ -38,7 +38,7 @@ export class WebviewPortMappingManager implements IDisposable {
if (mapping.webviewPort === requestLocalHostInfo.port) {
const extensionLocation = this._getExtensionLocation();
if (extensionLocation && extensionLocation.scheme === REMOTE_HOST_SCHEME) {
const tunnel = await this.getOrCreateTunnel(resolveAuthority, mapping.extensionHostPort);
const tunnel = resolveAuthority && await this.getOrCreateTunnel(resolveAuthority, mapping.extensionHostPort);
if (tunnel) {
if (tunnel.tunnelLocalPort === mapping.webviewPort) {
return undefined;

View File

@@ -36,9 +36,9 @@ export class WebviewPortMappingProvider extends Disposable {
sess.webRequest.onBeforeRequest({
urls: [
'*://localhost:*/',
'*://127.0.0.1:*/',
'*://0.0.0.0:*/',
'*://localhost:*/*',
'*://127.0.0.1:*/*',
'*://0.0.0.0:*/*',
]
}, async (details, callback) => {
const webviewId = details.webContentsId && this._webContentsIdsToWebviewIds.get(details.webContentsId);
@@ -47,7 +47,7 @@ export class WebviewPortMappingProvider extends Disposable {
}
const entry = this._webviewData.get(webviewId);
if (!entry || !entry.metadata.resolvedAuthority) {
if (!entry) {
return callback({});
}