From 06f2c1b0c8552654d5152fd0570a9b0e856b450a Mon Sep 17 00:00:00 2001 From: jean-emmanuel Date: Tue, 8 Feb 2022 18:35:45 +0100 Subject: [PATCH] clone: prevent freeze and print an error when attempting to create a circular clone --- CHANGELOG.md | 1 + src/client/widgets/containers/clone.js | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f095e8fe..580b6357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - bug fixes - inspector: script editor: cursor alignment issue in indented lines + - clone: prevent freeze and print an error when attempting to create a circular clone ## 1.14.5 diff --git a/src/client/widgets/containers/clone.js b/src/client/widgets/containers/clone.js index 428a9f53..defc2c40 100644 --- a/src/client/widgets/containers/clone.js +++ b/src/client/widgets/containers/clone.js @@ -53,6 +53,15 @@ class Clone extends Container() { this.container.classList.add('empty') + var parent = this.parent + while (parent !== widgetManager) { + if (parent.getProp('id') === this.getProp('widgetId')) { + this.errorProp('widgetId', 'circular reference', 'cannot create clone: target widget is a parent of this clone.') + return + } + parent = parent.parent + } + this.bindTarget(this.getCloneTarget()) if (this.cloneTarget) this.createClone(true)