Skip to content

Commit 022c480

Browse files
committed
Merge webview origin patch into webview patch
1 parent 1945220 commit 022c480

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

patches/series

-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,3 @@ service-worker.diff
1717
connection-type.diff
1818
sourcemaps.diff
1919
disable-downloads.diff
20-
parent-origin.diff

patches/webview.diff

+20
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ Since this code exists only for the authentication case we can just skip it when
1515
it is served from the current host as authentication is not a problem if the
1616
request is not cross-origin.
1717

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+
1821
To test, open a few types of webviews (images, markdown, extension details, etc).
1922

2023
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
7477
switch (event.request.method) {
7578
case 'GET':
7679
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

Comments
 (0)