chore: use indirect eval, avoid exposing stuff to the global scope (#11646)

* chore: use indirect eval, avoid exposing stuff to the global scope

* prettier
pull/11645/head
Rich Harris 1 year ago committed by GitHub
parent c131e6f494
commit 2e7e399160
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -85,7 +85,7 @@
if (action === 'eval') { if (action === 'eval') {
try { try {
const { script } = ev.data.args; const { script } = ev.data.args;
eval(script); (0, eval)(script);
send_ok(); send_ok();
} catch (e) { } catch (e) {
send_error(e.message, e.stack); send_error(e.message, e.stack);
@ -140,7 +140,6 @@
window.addEventListener('unhandledrejection', (event) => { window.addEventListener('unhandledrejection', (event) => {
parent.postMessage({ action: 'unhandledrejection', value: event.reason }, '*'); parent.postMessage({ action: 'unhandledrejection', value: event.reason }, '*');
}); });
}).call(this);
let previous = { level: null, args: null }; let previous = { level: null, args: null };
@ -200,7 +199,11 @@
); );
} else { } else {
parent.postMessage( parent.postMessage(
{ action: 'console', level: 'system-warn', args: [`Timer '${label}' does not exist`] }, {
action: 'console',
level: 'system-warn',
args: [`Timer '${label}' does not exist`]
},
'*' '*'
); );
} }
@ -219,7 +222,11 @@
); );
} else { } else {
parent.postMessage( parent.postMessage(
{ action: 'console', level: 'system-warn', args: [`Timer '${label}' does not exist`] }, {
action: 'console',
level: 'system-warn',
args: [`Timer '${label}' does not exist`]
},
'*' '*'
); );
} }
@ -294,6 +301,7 @@
return null; return null;
} }
} }
})();
</script> </script>
</head> </head>
<body></body> <body></body>

Loading…
Cancel
Save