From f73e9225b480aafdd35a2acbee952f72a1cc22f5 Mon Sep 17 00:00:00 2001 From: Asher Date: Fri, 25 Oct 2019 15:52:39 -0500 Subject: [PATCH] Remove directory restrictions for /webview/vscode-resource This makes viewing images work. Fixes #1111. --- src/node/server.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/node/server.ts b/src/node/server.ts index ab7ca0d54..6147ed14e 100644 --- a/src/node/server.ts +++ b/src/node/server.ts @@ -193,6 +193,11 @@ export abstract class Server { return { content: await util.promisify(fs.readFile)(filePath), filePath }; } + protected async getAnyResource(...parts: string[]): Promise { + const filePath = path.join(...parts); + return { content: await util.promisify(fs.readFile)(filePath), filePath }; + } + protected async getTarredResource(...parts: string[]): Promise { const filePath = this.ensureAuthorizedFilePath(...parts); return { stream: tarFs.pack(filePath), filePath, mime: "application/tar", cache: true }; @@ -524,7 +529,7 @@ export class MainServer extends Server { break; case "/webview": if (/^\/vscode-resource/.test(requestPath)) { - return this.getResource(requestPath.replace(/^\/vscode-resource(\/file)?/, "")); + return this.getAnyResource(requestPath.replace(/^\/vscode-resource(\/file)?/, "")); } return this.getResource( this.rootPath,