Auto rewrite vscode-resource entries in csp in web iframe based webviews

This commit is contained in:
Matt Bierner 2019-08-20 14:18:13 -07:00
parent e44d9a2888
commit e37d0e7e43
2 changed files with 7 additions and 1 deletions

View file

@ -289,6 +289,11 @@
const csp = newDocument.querySelector('meta[http-equiv="Content-Security-Policy"]');
if (!csp) {
host.postMessage('no-csp-found');
} else {
// Rewrite vscode-resource in csp
if (data.endpoint) {
csp.setAttribute('content', csp.getAttribute('content').replace(/vscode-resource:/g, data.endpoint));
}
}
// set DOCTYPE for newDocument explicitly as DOMParser.parseFromString strips it off

View file

@ -202,7 +202,8 @@ export class IFrameWebview extends Disposable implements Webview {
this._send('content', {
contents: this.content.html,
options: this.content.options,
state: this.content.state
state: this.content.state,
endpoint: this.endpoint,
});
}