scripting: prevent crash (built-in client only) when using the variable navigator
This commit is contained in:
parent
6813be50fb
commit
f3acec538f
3 changed files with 8 additions and 1 deletions
|
|
@ -6,6 +6,7 @@
|
|||
- button: allow writing strings like `"1.0"` in `label` without removing the decimals
|
||||
- editor: use css variable `--grid-width` at startup and after disabling & enabling the grid
|
||||
- launcher: regression preventing server halt when built-in client is closed manually beforehand
|
||||
- scripting: prevent crash (built-in client only) when using the variable `navigator`
|
||||
|
||||
- widgets
|
||||
- menu/switch/dropdown: reset value to `undefined` when receiving a value that's not defined in `values`
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ class UiConsole extends UiSidePanel {
|
|||
|
||||
this.script = new Script({props:{
|
||||
id: 'CONSOLE',
|
||||
script: 'return eval(value)',
|
||||
// detached context++ reading global navigator == crash electron
|
||||
script: 'var navigator; return eval(value)',
|
||||
event: 'value'
|
||||
}, parent: widgetManager})
|
||||
this.script._not_editable = true
|
||||
|
|
|
|||
|
|
@ -90,6 +90,11 @@ class Vm {
|
|||
contextKeys = ['__VARS'],
|
||||
contextValues = [{}]
|
||||
|
||||
// detached context + reading global navigator == crash electron
|
||||
if (code.indexOf('navigator') !== -1) {
|
||||
contextInit += 'var navigator;'
|
||||
}
|
||||
|
||||
if (defaultContext) {
|
||||
for (var k in defaultContext) {
|
||||
contextInit += `var ${k} = ${k} === undefined ? ${JSON.stringify(defaultContext[k])} : ${k};`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue