Archived
1
0

Remove directory restrictions for /webview/vscode-resource

This makes viewing images work. Fixes #1111.
This commit is contained in:
Asher 2019-10-25 15:52:39 -05:00
parent 168ccb0dfc
commit f73e9225b4
No known key found for this signature in database
GPG Key ID: D63C1EF81242354A

View File

@ -193,6 +193,11 @@ export abstract class Server {
return { content: await util.promisify(fs.readFile)(filePath), filePath }; return { content: await util.promisify(fs.readFile)(filePath), filePath };
} }
protected async getAnyResource(...parts: string[]): Promise<Response> {
const filePath = path.join(...parts);
return { content: await util.promisify(fs.readFile)(filePath), filePath };
}
protected async getTarredResource(...parts: string[]): Promise<Response> { protected async getTarredResource(...parts: string[]): Promise<Response> {
const filePath = this.ensureAuthorizedFilePath(...parts); const filePath = this.ensureAuthorizedFilePath(...parts);
return { stream: tarFs.pack(filePath), filePath, mime: "application/tar", cache: true }; return { stream: tarFs.pack(filePath), filePath, mime: "application/tar", cache: true };
@ -524,7 +529,7 @@ export class MainServer extends Server {
break; break;
case "/webview": case "/webview":
if (/^\/vscode-resource/.test(requestPath)) { if (/^\/vscode-resource/.test(requestPath)) {
return this.getResource(requestPath.replace(/^\/vscode-resource(\/file)?/, "")); return this.getAnyResource(requestPath.replace(/^\/vscode-resource(\/file)?/, ""));
} }
return this.getResource( return this.getResource(
this.rootPath, this.rootPath,