From 66c68a734efb970c5b4916c09dcac97eac9b973d Mon Sep 17 00:00:00 2001 From: bordun Date: Sat, 21 Mar 2020 12:41:26 +0100 Subject: [PATCH] editor: keybinding clean vm: global globals --- src/client/editor/index.js | 3 ++- src/client/widgets/vm.js | 15 ++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/client/editor/index.js b/src/client/editor/index.js index 53be7876..b6b83ef1 100644 --- a/src/client/editor/index.js +++ b/src/client/editor/index.js @@ -168,7 +168,8 @@ class Editor { handleKeyboard(combo, e){ - if (e.target && e.target.classList.contains('no-keybinding')) return + if (e.target && (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT')) return + e.preventDefault() switch (combo) { diff --git a/src/client/widgets/vm.js b/src/client/widgets/vm.js index 18286d0f..d06ca7ec 100644 --- a/src/client/widgets/vm.js +++ b/src/client/widgets/vm.js @@ -1,5 +1,11 @@ var loopProtect = require('loop-protect'), - {deepCopy} = require('../utils') + {deepCopy} = require('../utils'), + globals = { + screen: {width: screen.width, height: screen.height}, + env: deepCopy(ENV), + url: document.location.host, + platform: navigator.platform + } class Vm { @@ -42,12 +48,7 @@ class Vm { this.sandbox.contentWindow.setInterval = ()=>{ throw 'setTimeout and setInterval can\'t be used in the JS sandbox' } - this.sandbox.contentWindow.globals = { - screen: {width: screen.width, height: screen.height}, - env: deepCopy(ENV), - url: document.location.host, - platform: navigator.platform - } + this.sandbox.contentWindow.globals = globals // sanitize globals for (var imports of ['__protect', 'console', 'setTimeout', 'setInterval', 'globals']) {