@@ -15,6 +15,9 @@ Since this code exists only for the authentication case we can just skip it when
15
15
it is served from the current host as authentication is not a problem if the
16
16
request is not cross-origin.
17
17
18
+ There is also an origin check we bypass (this seems to be related to how the
19
+ webview host is separate by default but we serve on the same host).
20
+
18
21
To test, open a few types of webviews (images, markdown, extension details, etc).
19
22
20
23
Index: code-server/lib/vscode/src/vs/workbench/services/environment/browser/environmentService.ts
@@ -74,3 +77,20 @@ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/servi
74
77
switch (event.request.method) {
75
78
case 'GET':
76
79
case 'HEAD':
80
+ Index: code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js
81
+ ===================================================================
82
+ --- code-server.orig/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js
83
+ +++ code-server/lib/vscode/src/vs/workbench/contrib/webview/browser/pre/main.js
84
+ @@ -318,6 +318,12 @@ const hostMessaging = new class HostMess
85
+
86
+ const hostname = location.hostname;
87
+
88
+ + // It is safe to run if we are on the same host.
89
+ + const parent = new URL(parentOrigin)
90
+ + if (parent.hostname === location.hostname) {
91
+ + return start(parentOrigin)
92
+ + }
93
+ +
94
+ if (!crypto.subtle) {
95
+ // cannot validate, not running in a secure context
96
+ throw new Error(`Cannot validate in current context!`);
0 commit comments