diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 1244b6e6..00000000 --- a/.babelrc +++ /dev/null @@ -1,12 +0,0 @@ -{ - "presets": [ - ["@babel/env", { - "targets": { - "ios": "10.3", - "chrome": "60" - }, - "useBuiltIns": "usage", - "corejs": 3 - }] - ] -} diff --git a/CHANGELOG.md b/CHANGELOG.md index 51a25883..0ae16792 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,13 @@ - widgets - the html property is no longer restricted / sanitized - input/textarea/select no longer have their appearance property reset in custom html + - canvas: added `contextType` property +- scripting + - user scripts are longer protected against infinite loop and the main window object may be reached (it's not supported to break out of scripting context, but resources are no longer wasted to prevent it) + +- breaking change + - dropped support for iOS 10.3 ## 1.29.8 diff --git a/scripts/client.rollup.config.js b/scripts/client.rollup.config.js index 81cc45b4..156a29f3 100644 --- a/scripts/client.rollup.config.js +++ b/scripts/client.rollup.config.js @@ -14,13 +14,12 @@ module.exports = { input: 'src/client/index.mjs', output: [ { - file: 'app/client/index.js', - inlineDynamicImports: true, - format: 'iife', + dir: 'app/client/', + hoistTransitiveImports:true, + chunkFileNames: `[name]-${package.version}.js`, + entryFileNames: `[name]-${package.version}.js`, + format: 'es', sourcemap: true, - strict: false, - indent: false, - name: '_' }, ], treeshake: false, @@ -44,8 +43,8 @@ module.exports = { '@babel/preset-env', { targets: { - ios: '10.3', - chrome: '60' + ios: '11', + chrome: '61' }, useBuiltIns: 'usage', corejs: 3, diff --git a/src/client/widgets/scripts/script-vm.mjs b/src/client/widgets/scripts/script-vm.mjs index c897eb43..7d397c1e 100644 --- a/src/client/widgets/scripts/script-vm.mjs +++ b/src/client/widgets/scripts/script-vm.mjs @@ -591,7 +591,6 @@ class ScriptVm extends Vm { for (var imports of ['set', 'get', 'getProp', 'getIndex', 'updateProp', 'send', 'httpGet', 'stateGet', 'stateSet', 'storage', 'setInterval', 'clearInterval', 'setTimeout', 'cthislearTimeout', 'setFocus', 'unfocus' , 'setFocusable', 'setScroll', 'getScroll', 'toolbar', 'openUrl', 'getVar', 'setVar', 'runAs', 'reload', 'Image', 'updateCanvas', 'getNavigator', 'browseFile']) { - this.sanitize(this.sandbox.contentWindow[imports]) this.globals[imports] = true } diff --git a/src/client/widgets/vm.mjs b/src/client/widgets/vm.mjs index e27c13cb..e3e1f82d 100644 --- a/src/client/widgets/vm.mjs +++ b/src/client/widgets/vm.mjs @@ -1,4 +1,3 @@ -import loopProtect from 'loop-protect' import {deepCopy} from '../utils.mjs' var sessionManager @@ -50,13 +49,6 @@ class Vm { this.sandbox.contentWindow.document.write('') this.sandbox.contentWindow.document.close() - // init infinite loop guard - loopProtect.alias = '__protect' - loopProtect.hit = function(line){ - throw 'Potential infinite loop found on line ' + line + '(script interrupted).\nAdd "// noprotect" to your code to disable loop protection.' - } - this.sandbox.contentWindow.__protect = loopProtect - // global context this.registerGlobals() @@ -94,32 +86,6 @@ class Vm { } this.sandbox.contentWindow.globals = globals - // sanitize globals - for (var imports of ['__protect', 'console', 'setTimeout', 'setInterval', 'globals']) { - this.sanitize(this.sandbox.contentWindow[imports]) - } - - } - - sanitize(object) { - - // non-primitives created outside the sandbox context can leak - // the host window object... let's nuke that ! - // (we only nuke functions and objects/arrays because we don't pass anything else) - var t = typeof o - if (t === 'function' || (t === 'object' && o !== null)) { - if (o.__proto__) { - if (t === 'function') { - o.__proto__.constructor = this.safeFunctionProto - } else { - o.__proto__.constructor.constructor = this.safeFunctionProto - } - } - for (var k in o) { - this.sanitize(o[k]) - } - } - } compile(code, defaultContext) { @@ -127,7 +93,7 @@ class Vm { if (typeof code !== 'string') code = String(code) // var contextInit = 'var locals = locals;', - var contextInit = '', + var contextInit = '"use strict";', contextKeys = ['__VARS'], contextValues = [{}] @@ -144,13 +110,9 @@ class Vm { } } - var compiledCode = new this.safeFunctionProto( - ...contextKeys, 'locals', - loopProtect('"use strict";' + contextInit + code) - .replace(/;\n(if \(__protect.*break;)\n/g, ';$1') // prevent loop protect from breaking stack linenumber - .replace(/(VAR_[0-9]+)/g, '__VARS.$1') - ) + code = contextInit + code.replace(/(VAR_[0-9]+)/g, '__VARS.$1') + var compiledCode = new this.safeFunctionProto(...contextKeys, 'locals', code) return (context, locals)=>{ @@ -167,8 +129,6 @@ class Vm { __contextValues.push(locals) - this.sanitize(__contextValues) - return compiledCode.apply('this', __contextValues) } diff --git a/src/docs/client-shim.mjs b/src/docs/client-shim.mjs index 31956714..90628831 100644 --- a/src/docs/client-shim.mjs +++ b/src/docs/client-shim.mjs @@ -1,5 +1,5 @@ // Dirty browser window shim -import * as DOM from '../client/dom' +import * as DOM from '../client/dom.mjs' // eslint-disable-next-line no-global-assign document = { diff --git a/src/html/client.html b/src/html/client.html index 2b8b90f9..bcc620c4 100644 --- a/src/html/client.html +++ b/src/html/client.html @@ -15,7 +15,7 @@ - + diff --git a/src/server/node/server.mjs b/src/server/node/server.mjs index 4ae2044e..1e85ed36 100644 --- a/src/server/node/server.mjs +++ b/src/server/node/server.mjs @@ -163,7 +163,7 @@ class WebServer extends EventEmitter { if ( url.indexOf('__OSC_ASSET__=1') != -1 || url.indexOf('open-stage-control-client.js.map') != -1 || - url.indexOf('/client/ace/') != -1 + url.indexOf('/client/') == 0 ) { // osc asset files