From 1aa3fbfef5ec367a80440e44c07dad548dbda070 Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 30 Dec 2025 17:34:05 +0100 Subject: [PATCH] script-vm: fix setTimeout/setInterval override --- src/client/widgets/vm.mjs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/client/widgets/vm.mjs b/src/client/widgets/vm.mjs index 4a8b2cbd..24124ecd 100644 --- a/src/client/widgets/vm.mjs +++ b/src/client/widgets/vm.mjs @@ -53,6 +53,19 @@ class Vm { // global context this.globals = {} + this.globals.console = { + ...console, + log: (...msg)=>{ + msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m) + this.getWidget().log(msg.join(' ')) + } + } + + this.globals.setTimeout = + this.globals.setInterval = ()=>{ + throw 'setTimeout and setInterval can\'t be used in the JS sandbox' + } + this.registerGlobals() // detach sandbox @@ -75,19 +88,6 @@ class Vm { registerGlobals() { - this.globals.console = { - ...console, - log: (...msg)=>{ - msg = msg.map(m => typeof m == 'object' ? JSON.stringify(m) : m) - this.getWidget().log(msg.join(' ')) - } - } - - this.globals.setTimeout = - this.globals.setInterval = ()=>{ - throw 'setTimeout and setInterval can\'t be used in the JS sandbox' - } - this.globals.globals = globals for (var k in this.globals) {