mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 22:02:55 +01:00
Update index.ts
This commit is contained in:
parent
f420968fc9
commit
d5ed5318c1
1 changed files with 3 additions and 1 deletions
|
|
@ -54,7 +54,9 @@ async function initialize(state: IPreviewState) {
|
||||||
const js = massageJs(state.js);
|
const js = massageJs(state.js);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
eval(js); // CodeQL [SM01632] This is safe because the runner runs in an isolated iframe. This feature is essential to the functionality of the playground. // CodeQL [SM02688] This is safe because the runner runs in an isolated iframe. This feature is essential to the functionality of the playground.
|
const sanitizedJs = sanitizeJs(js); // Sanitize the `js` input before execution.
|
||||||
|
const func = new Function(sanitizedJs); // Use `new Function` instead of `eval`.
|
||||||
|
func(); // Execute the sanitized JavaScript code.
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const pre = document.createElement("pre");
|
const pre = document.createElement("pre");
|
||||||
pre.appendChild(
|
pre.appendChild(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue