@@ -10,16 +10,14 @@ Index: code-server/lib/vscode/src/vs/base/common/network.ts
10
10
===================================================================
11
11
--- code-server.orig/lib/vscode/src/vs/base/common/network.ts
12
12
+++ code-server/lib/vscode/src/vs/base/common/network.ts
13
- @@ -151,8 +151,10 @@ class RemoteAuthoritiesImpl {
14
- }
13
+ @@ -157,7 +157,9 @@ class RemoteAuthoritiesImpl {
15
14
return URI.from({
16
15
scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource,
17
- - authority: `${host}:${port}`,
18
- - path: `/vscode-remote-resource`,
19
- + authority: platform.isWeb ? window.location.host : `${host}:${port}`,
16
+ authority: `${host}:${port}`,
17
+ - path: this._remoteResourcesPath,
20
18
+ path: platform.isWeb
21
- + ? URI.joinPath(URI.parse( window.location.href), `/vscode-remote-resource`).path
22
- + : `/vscode-remote-resource` ,
19
+ + ? ( window.location.pathname + "/" + this._remoteResourcesPath).replace(/\/\/+/g, "/")
20
+ + : this._remoteResourcesPath ,
23
21
query
24
22
});
25
23
}
@@ -38,40 +36,28 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench-dev.html
38
36
39
37
<!-- Disable pinch zooming -->
40
38
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
41
- @@ -27,23 +27,26 @@
39
+ @@ -27,9 +27,9 @@
42
40
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
43
41
44
42
<!-- Workbench Icon/Manifest/CSS -->
45
43
- <link rel="icon" href="/_static/src/browser/media/favicon-dark-support.svg" />
46
- - <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" />
44
+ - <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" type="image/x-icon" />
47
45
- <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
48
46
+ <link rel="icon" href="{{BASE}}/_static/src/browser/media/favicon-dark-support.svg" />
49
- + <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" />
47
+ + <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" type="image/x-icon" />
50
48
+ <link rel="manifest" href="{{VS_BASE}}/manifest.json" crossorigin="use-credentials" />
51
49
</head>
52
50
53
51
<body aria-label="">
54
- </body>
55
-
56
- <!-- Startup (do not modify order of script tags!) -->
57
- - <script src="./static/out/vs/loader.js"></script>
58
- - <script src="./static/out/vs/webPackagePaths.js"></script>
59
- + <script src="{{VS_BASE}}/static/out/vs/loader.js"></script>
60
- + <script src="{{VS_BASE}}/static/out/vs/webPackagePaths.js"></script>
52
+ @@ -39,7 +39,7 @@
53
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
54
+ <script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
61
55
<script>
56
+ - const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
57
+ + const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location).toString();
62
58
Object.keys(self.webPackagePaths).map(function (key, index) {
63
- - self.webPackagePaths[key] = `${window.location.origin}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
64
- + self.webPackagePaths[key] = new URL(
65
- + `{{VS_BASE}}/static/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`,
66
- + window.location,
67
- + ).toString();
59
+ self.webPackagePaths[key] = `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
68
60
});
69
- require.config({
70
- - baseUrl: `${window.location.origin}/static/out`,
71
- + baseUrl: new URL(`{{VS_BASE}}/static/out`, window.location).toString(),
72
- recordStats: true,
73
- trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
74
- createScriptURL(value) {
75
61
Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
76
62
===================================================================
77
63
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.html
@@ -87,68 +73,32 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.html
87
73
88
74
<!-- Disable pinch zooming -->
89
75
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
90
- @@ -24,10 +24,10 @@
76
+ @@ -24,9 +24,9 @@
91
77
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
92
78
93
79
<!-- Workbench Icon/Manifest/CSS -->
94
80
- <link rel="icon" href="/_static/src/browser/media/favicon-dark-support.svg" />
95
- - <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" />
81
+ - <link rel="alternate icon" href="/_static/src/browser/media/favicon.ico" type="image/x-icon" />
96
82
- <link rel="manifest" href="/manifest.json" crossorigin="use-credentials" />
97
- - <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="./static/out/vs/workbench/workbench.web.main.css">
98
83
+ <link rel="icon" href="{{BASE}}/_static/src/browser/media/favicon-dark-support.svg" />
99
- + <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" />
84
+ + <link rel="alternate icon" href="{{BASE}}/_static/src/browser/media/favicon.ico" type="image/x-icon" />
100
85
+ <link rel="manifest" href="{{VS_BASE}}/manifest.json" crossorigin="use-credentials" />
101
- + <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{VS_BASE}}/static /out/vs/workbench/workbench.web.main.css">
86
+ <link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}} /out/vs/workbench/workbench.web.main.css">
102
87
103
88
</head>
104
-
105
- @@ -35,14 +35,17 @@
106
- </body>
107
-
108
- <!-- Startup (do not modify order of script tags!) -->
109
- - <script src="./static/out/vs/loader.js"></script>
110
- - <script src="./static/out/vs/webPackagePaths.js"></script>
111
- + <script src="{{VS_BASE}}/static/out/vs/loader.js"></script>
112
- + <script src="{{VS_BASE}}/static/out/vs/webPackagePaths.js"></script>
113
- <script>
114
- Object.keys(self.webPackagePaths).map(function (key, index) {
115
- - self.webPackagePaths[key] = `${window.location.origin}/static/node_modules/${key}/${self.webPackagePaths[key]}`;
116
- + self.webPackagePaths[key] = new URL(
117
- + `{{VS_BASE}}/static/node_modules/${key}/${self.webPackagePaths[key]}`,
118
- + window.location,
119
- + ).toString();
120
- });
121
- require.config({
122
- - baseUrl: `${window.location.origin}/static/out`,
123
- + baseUrl: new URL(`{{VS_BASE}}/static/out`, window.location).toString(),
124
- recordStats: true,
125
- trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
126
- createScriptURL(value) {
127
- @@ -55,7 +58,7 @@
128
- <script>
129
- performance.mark('code/willLoadWorkbenchMain');
130
- </script>
131
- - <script src="./static/out/vs/workbench/workbench.web.main.nls.js"></script>
132
- - <script src="./static/out/vs/workbench/workbench.web.main.js"></script>
133
- - <script src="./static/out/vs/code/browser/workbench/workbench.js"></script>
134
- + <script src="{{VS_BASE}}/static/out/vs/workbench/workbench.web.main.nls.js"></script>
135
- + <script src="{{VS_BASE}}/static/out/vs/workbench/workbench.web.main.js"></script>
136
- + <script src="{{VS_BASE}}/static/out/vs/code/browser/workbench/workbench.js"></script>
137
- </html>
138
89
Index: code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
139
90
===================================================================
140
91
--- code-server.orig/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
141
92
+++ code-server/lib/vscode/src/vs/platform/remote/browser/browserSocketFactory.ts
142
- @@ -274,7 +274,7 @@ export class BrowserSocketFactory implem
93
+ @@ -274,6 +274,7 @@ export class BrowserSocketFactory implem
143
94
144
- connect(host: string, port: number, query: string, debugLabel: string, callback: IConnectCallback): void {
95
+ connect(host: string, port: number, path: string, query: string, debugLabel: string, callback: IConnectCallback): void {
145
96
const webSocketSchema = (/^https:/.test(window.location.href) ? 'wss' : 'ws');
146
- - const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test(host) ? `[${host}]` : host}:${port}/?${query}&skipWebSocketFrames=false`, debugLabel);
147
- + const socket = this._webSocketFactory.create(`${webSocketSchema}://${window.location. host}${window.location.pathname }?${query}&skipWebSocketFrames=false`, debugLabel);
97
+ + path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
98
+ const socket = this._webSocketFactory.create(`${webSocketSchema}://${/:/.test( host) ? `[${host}]` : host}:${port}${path }?${query}&skipWebSocketFrames=false`, debugLabel);
148
99
const errorListener = socket.onError((err) => callback(err, undefined));
149
100
socket.onOpen(() => {
150
- errorListener.dispose();
151
- @@ -282,6 +282,3 @@ export class BrowserSocketFactory implem
101
+ @@ -282,6 +283,3 @@ export class BrowserSocketFactory implem
152
102
});
153
103
}
154
104
}
@@ -159,47 +109,56 @@ Index: code-server/lib/vscode/src/vs/server/node/webClientServer.ts
159
109
===================================================================
160
110
--- code-server.orig/lib/vscode/src/vs/server/node/webClientServer.ts
161
111
+++ code-server/lib/vscode/src/vs/server/node/webClientServer.ts
162
- @@ -253,7 +253 ,10 @@ export class WebClientServer {
112
+ @@ -267,14 +267 ,10 @@ export class WebClientServer {
163
113
return res.end();
164
114
}
165
115
166
- - const remoteAuthority = req.headers.host;
116
+ - let originalHost = req.headers['x-original-host'];
117
+ - if (Array.isArray(originalHost)) {
118
+ - originalHost = originalHost[0];
119
+ - }
120
+ - const remoteAuthority = originalHost || req.headers.host;
121
+ - if (!remoteAuthority) {
122
+ - return serveError(req, res, 400, `Bad request.`);
123
+ - }
167
124
+ // It is not possible to reliably detect the remote authority on the server
168
125
+ // in all cases. Set this to something invalid to make sure we catch code
169
126
+ // that is using this when it should not.
170
127
+ const remoteAuthority = 'remote';
171
128
172
- function escapeAttribute(value: string): string {
173
- return value.replace(/"/g, '"');
174
- @@ -275,6 +278,8 @@ export class WebClientServer {
175
- accessToken: this._environmentService.args['github-auth'],
129
+ function asJSON(value: unknown): string {
130
+ return JSON.stringify(value).replace(/"/g, '"');
131
+ @@ -297,6 +293,8 @@ export class WebClientServer {
176
132
scopes: [['user:email'], ['repo']]
177
133
} : undefined;
134
+
178
135
+ const base = relativeRoot(getOriginalUrl(req))
179
136
+ const vscodeBase = relativePath(getOriginalUrl(req))
180
- const data = (await util.promisify(fs.readFile)(filePath)).toString()
181
- .replace('{{WORKBENCH_WEB_CONFIGURATION}}', escapeAttribute(JSON.stringify({
182
- remoteAuthority,
183
- @@ -285,6 +290,7 @@ export class WebClientServer {
184
- folderUri: resolveWorkspaceURI(this._environmentService.args['default-folder']),
185
- workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
186
- productConfiguration: <Partial<IProductConfiguration>>{
187
- + rootEndpoint: base,
188
- codeServerVersion: this._productService.codeServerVersion,
189
- embedderIdentifier: 'server-distro',
190
- extensionsGallery: this._webExtensionResourceUrlTemplate ? {
191
- @@ -297,7 +303,9 @@ export class WebClientServer {
192
- } : undefined
193
- }
194
- })))
195
- - .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '');
196
- + .replace('{{WORKBENCH_AUTH_SESSION}}', () => authSessionInfo ? escapeAttribute(JSON.stringify(authSessionInfo)) : '')
197
- + .replace(/{{BASE}}/g, base)
198
- + .replace(/{{VS_BASE}}/g, vscodeBase);
199
137
200
- const cspDirectives = [
201
- 'default-src \'self\';',
202
- @@ -376,3 +384,70 @@ export class WebClientServer {
138
+ const workbenchWebConfiguration = {
139
+ remoteAuthority,
140
+ @@ -308,6 +306,7 @@ export class WebClientServer {
141
+ workspaceUri: resolveWorkspaceURI(this._environmentService.args['default-workspace']),
142
+ productConfiguration: <Partial<IProductConfiguration>>{
143
+ codeServerVersion: this._productService.codeServerVersion,
144
+ + rootEndpoint: base,
145
+ embedderIdentifier: 'server-distro',
146
+ extensionsGallery: this._webExtensionResourceUrlTemplate ? {
147
+ ...this._productService.extensionsGallery,
148
+ @@ -328,8 +327,10 @@ export class WebClientServer {
149
+ const values: { [key: string]: string } = {
150
+ WORKBENCH_WEB_CONFIGURATION: asJSON(workbenchWebConfiguration),
151
+ WORKBENCH_AUTH_SESSION: authSessionInfo ? asJSON(authSessionInfo) : '',
152
+ - WORKBENCH_WEB_BASE_URL: this._staticRoute,
153
+ - WORKBENCH_NLS_BASE_URL: nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : '',
154
+ + WORKBENCH_WEB_BASE_URL: vscodeBase + this._staticRoute,
155
+ + WORKBENCH_NLS_BASE_URL: vscodeBase + (nlsBaseUrl ? `${nlsBaseUrl}${this._productService.commit}/${this._productService.version}/` : ''),
156
+ + BASE: base,
157
+ + VS_BASE: vscodeBase,
158
+ };
159
+
160
+
161
+ @@ -419,3 +420,70 @@ export class WebClientServer {
203
162
return res.end(data);
204
163
}
205
164
}
@@ -286,20 +245,20 @@ Index: code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
286
245
===================================================================
287
246
--- code-server.orig/lib/vscode/src/vs/code/browser/workbench/workbench.ts
288
247
+++ code-server/lib/vscode/src/vs/code/browser/workbench/workbench.ts
289
- @@ -482 ,6 +482 ,7 @@ function doCreateUri(path: string, query
248
+ @@ -485 ,6 +485 ,7 @@ function doCreateUri(path: string, query
290
249
});
291
250
}
292
251
293
252
+ path = (window.location.pathname + "/" + path).replace(/\/\/+/g, "/")
294
253
return URI.parse(window.location.href).with({ path, query });
295
254
}
296
255
297
- @@ -493 ,7 +494 ,7 @@ function doCreateUri(path: string, query
256
+ @@ -496 ,7 +497 ,7 @@ function doCreateUri(path: string, query
298
257
if (!configElement || !configElementAttribute) {
299
258
throw new Error('Missing web configuration element');
300
259
}
301
- - const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents } = JSON.parse(configElementAttribute);
302
- + const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents, workspaceUri?: UriComponents } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host }
260
+ - const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = JSON.parse(configElementAttribute);
261
+ + const config: IWorkbenchConstructionOptions & { folderUri?: UriComponents; workspaceUri?: UriComponents; callbackRoute: string } = { ...JSON.parse(configElementAttribute), remoteAuthority: location.host }
303
262
304
263
// Create workbench
305
264
create(document.body, {
@@ -312,10 +271,10 @@ Index: code-server/lib/vscode/src/vs/workbench/services/extensionResourceLoader/
312
271
import { TelemetryLevel } from 'vs/platform/telemetry/common/telemetry';
313
272
import { getTelemetryLevel, supportsTelemetry } from 'vs/platform/telemetry/common/telemetryUtils';
314
273
- import { RemoteAuthorities } from 'vs/base/common/network';
274
+ import { getRemoteServerRootPath } from 'vs/platform/remote/common/remoteHosts';
315
275
316
276
export const WEB_EXTENSION_RESOURCE_END_POINT = 'web-extension-resource';
317
-
318
- @@ -72,7 +71,7 @@ export abstract class AbstractExtensionR
277
+ @@ -75,7 +74,7 @@ export abstract class AbstractExtensionR
319
278
public getExtensionGalleryResourceURL(galleryExtension: { publisher: string; name: string; version: string }, path?: string): URI | undefined {
320
279
if (this._extensionGalleryResourceUrlTemplate) {
321
280
const uri = URI.parse(format2(this._extensionGalleryResourceUrlTemplate, { publisher: galleryExtension.publisher, name: galleryExtension.name, version: galleryExtension.version, path: 'extension' }));
0 commit comments