Skip to content

Commit f73e922

Browse files
committed
Remove directory restrictions for /webview/vscode-resource
This makes viewing images work. Fixes #1111.
1 parent 168ccb0 commit f73e922

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/node/server.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ export abstract class Server {
193193
return { content: await util.promisify(fs.readFile)(filePath), filePath };
194194
}
195195

196+
protected async getAnyResource(...parts: string[]): Promise<Response> {
197+
const filePath = path.join(...parts);
198+
return { content: await util.promisify(fs.readFile)(filePath), filePath };
199+
}
200+
196201
protected async getTarredResource(...parts: string[]): Promise<Response> {
197202
const filePath = this.ensureAuthorizedFilePath(...parts);
198203
return { stream: tarFs.pack(filePath), filePath, mime: "application/tar", cache: true };
@@ -524,7 +529,7 @@ export class MainServer extends Server {
524529
break;
525530
case "/webview":
526531
if (/^\/vscode-resource/.test(requestPath)) {
527-
return this.getResource(requestPath.replace(/^\/vscode-resource(\/file)?/, ""));
532+
return this.getAnyResource(requestPath.replace(/^\/vscode-resource(\/file)?/, ""));
528533
}
529534
return this.getResource(
530535
this.rootPath,

0 commit comments

Comments
 (0)