Skip to content

Commit

Permalink
Wrap into comment Content-Security-Policy meta tag
Browse files Browse the repository at this point in the history
Signed-off-by: Vitaliy Gulyy <vgulyy@redhat.com>
  • Loading branch information
vitaliy-guliy committed Jun 23, 2020
1 parent 3090899 commit 5dfae96
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/plugin-ext/src/main/browser/webview/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,17 @@ export class WebviewWidget extends BaseWidget implements StatefulWidget {
}

protected preprocessHtml(value: string): string {
return value
console.log('--------------------------------------------------------------------------------------');
console.log(value);
console.log('--------------------------------------------------------------------------------------');
// Comment <meta http-equiv="Content-Security-Policy" /> tag in HEAD section
let html = value
.replace(/<\s*meta([^>]+?(?=Content-Security-Policy)[^>]+)\/?>/gsm, (_, group) => {
return `<!-- meta ${group} -->`;
});

// Update all links, using 'vscode-resource:' and 'theia-resource:' scheme
return html
.replace(/(["'])(?:vscode|theia)-resource:(\/\/([^\s\/'"]+?)(?=\/))?([^\s'"]+?)(["'])/gi, (_, startQuote, _1, scheme, path, endQuote) => {
if (scheme) {
return `${startQuote}${this.externalEndpoint}/theia-resource/${scheme}${path}${endQuote}`;
Expand Down

0 comments on commit 5dfae96

Please sign in to comment.