From b462aaa9a35d92f02231fc39e1423d45942baee1 Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Tue, 7 Oct 2025 13:03:11 +0200 Subject: [PATCH] Modules in draft tidders should not be executed (#9293) * modules in draft tiddlers should not be defined * improve warning message and use console.warn --- boot/boot.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/boot/boot.js b/boot/boot.js index ece740468..0c7828abd 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -1532,7 +1532,8 @@ Define all modules stored in ordinary tiddlers */ $tw.Wiki.prototype.defineTiddlerModules = function() { this.each(function(tiddler,title) { - if(tiddler.hasField("module-type")) { + // Modules in draft tiddlers are disabled + if(tiddler.hasField("module-type") && (!tiddler.hasField("draft.of"))) { switch(tiddler.fields.type) { case "application/javascript": // We only define modules that haven't already been defined, because in the browser modules in system tiddlers are defined in inline script @@ -1559,6 +1560,11 @@ $tw.Wiki.prototype.defineShadowModules = function() { this.eachShadow(function(tiddler,title) { // Don't define the module if it is overidden by an ordinary tiddler if(!self.tiddlerExists(title) && tiddler.hasField("module-type")) { + if(tiddler.hasField("draft.of")) { + // Report a fundamental problem + console.warn(`TiddlyWiki: Plugins should not contain tiddlers with a 'draft.of' field: ${tiddler.fields.title}`); + return; + } // Define the module $tw.modules.define(tiddler.fields.title,tiddler.fields["module-type"],tiddler.fields.text); }