Adopt uuids for generating webview nonces

This commit is contained in:
Matt Bierner
2025-10-29 13:53:47 -07:00
parent f8e2f71c2f
commit c47a56c7bc
17 changed files with 291 additions and 45 deletions

View File

@@ -5,6 +5,7 @@
import * as vscode from 'vscode';
import { Disposable } from './dispose';
import { generateUuid } from './uuid';
export interface ShowOptions {
@@ -112,7 +113,7 @@ export class SimpleBrowserView extends Disposable {
private getHtml(url: string) {
const configuration = vscode.workspace.getConfiguration('simpleBrowser');
const nonce = getNonce();
const nonce = generateUuid();
const mainJs = this.extensionResourceUrl('media', 'index.js');
const mainCss = this.extensionResourceUrl('media', 'main.css');
@@ -181,12 +182,3 @@ export class SimpleBrowserView extends Disposable {
function escapeAttribute(value: string | vscode.Uri): string {
return value.toString().replace(/"/g, '"');
}
function getNonce() {
let text = '';
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
for (let i = 0; i < 64; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}