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
|
|
@ -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