Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/markdown-language-features/src/util/dom.ts
3292 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
import * as vscode from 'vscode';
6
7
export function escapeAttribute(value: string | vscode.Uri): string {
8
return value.toString()
9
.replace(/&/g, '&')
10
.replace(/"/g, '"')
11
.replace(/'/g, ''');
12
}
13
14
export function getNonce() {
15
let text = '';
16
const possible = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
17
for (let i = 0; i < 64; i++) {
18
text += possible.charAt(Math.floor(Math.random() * possible.length));
19
}
20
return text;
21
}
22
23