|
1 | 1 | import * as vscode from 'vscode'; |
2 | 2 | import * as path from 'path'; |
3 | 3 |
|
4 | | -import { IMRWebViewDetail } from './typings/commonTypes' |
| 4 | +import { IMRWebViewDetail } from './typings/commonTypes'; |
| 5 | +import { getNonce } from './common/utils'; |
5 | 6 |
|
6 | 7 | export class Panel { |
7 | 8 | /** |
@@ -142,27 +143,24 @@ export class Panel { |
142 | 143 | } |
143 | 144 |
|
144 | 145 | private _getHtmlForWebview(webview: vscode.Webview) { |
145 | | - const appPathOnDisk = vscode.Uri.file(path.join(this._extensionPath, 'out/webviews/main.js')); |
146 | | - const appUri = appPathOnDisk.with({ scheme: 'vscode-resource' }); |
| 146 | + const appPathOnDisk = vscode.Uri.joinPath(this._extensionUri, 'out/webviews/main.js'); |
| 147 | + const appUri = webview.asWebviewUri(appPathOnDisk); |
| 148 | + const nonce = getNonce(); |
147 | 149 |
|
148 | 150 | return `<!DOCTYPE html> |
149 | 151 | <html lang="en"> |
150 | 152 | <head> |
151 | 153 | <meta charset="UTF-8"> |
152 | | - <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
153 | 154 | <title>Merge Request Overview</title> |
154 | | -
|
| 155 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
155 | 156 | <meta http-equiv="Content-Security-Policy" |
156 | | - content="default-src 'unsafe-inline'; |
157 | | - img-src https:; |
158 | | - script-src 'unsafe-eval' 'unsafe-inline' vscode-resource:; |
159 | | - connect-src 'self' https: *.coding.net; |
160 | | - style-src vscode-resource: 'unsafe-inline';"> |
| 157 | + content="default-src 'unsafe-eval'; style-src vscode-resource: 'unsafe-inline' http: https: data:;; img-src vscode-resource: https:; script-src 'nonce-${nonce}' 'unsafe-eval'; connect-src https:"> |
161 | 158 | </head> |
162 | 159 | <body> |
163 | 160 | <div id="root"></div> |
164 | | - <script src="${appUri}"></script> |
| 161 | + <script nonce="${nonce}" src="${appUri}"></script> |
165 | 162 | </body> |
166 | 163 | </html>`; |
167 | 164 | } |
168 | 165 | } |
| 166 | + |
0 commit comments