From 48619163d551b2fa9b64e09626b48c8680071551 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 11 Mar 2021 02:04:22 +0000 Subject: [PATCH 1/2] //multi: gracefully handle empty invocations; ensure args is always set if it isn't found via the :find() call, then set it to an empty string. This prevents crashes where the callee expects to be passed a string --- worldeditadditions_commands/commands/meta/multi.lua | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/worldeditadditions_commands/commands/meta/multi.lua b/worldeditadditions_commands/commands/meta/multi.lua index 69dd6e1..1be4dca 100644 --- a/worldeditadditions_commands/commands/meta/multi.lua +++ b/worldeditadditions_commands/commands/meta/multi.lua @@ -36,6 +36,10 @@ minetest.register_chatcommand("/multi", { description = "Executes multiple chat commands in sequence. Just prepend a list of space-separated chat commands with //multi, and you're good to go! The forward slashes at the beginning of each chat command must be the same as if you were executing it normally.", privs = { worldedit = true }, func = function(name, params_text) + if not params_text then return false, "Error: No commands specified, so there's nothing to do." end + params_text = worldeditadditions.trim(params_text) + if #params_text == 0 then return false, "Error: No commands specified, so there's nothing to do." end + local i = 1 -- For feedback only local master_start_time = worldeditadditions.get_ms_time() @@ -47,6 +51,7 @@ minetest.register_chatcommand("/multi", { local found, _, command_name, args = command:find("^([^%s]+)%s(.+)$") if not found then command_name = command end command_name = trim(command_name) + if not args then args = "" end worldedit.player_notify(name, "#"..i..": /"..command) @@ -55,9 +60,9 @@ minetest.register_chatcommand("/multi", { return false, "Error: "..command_name.." isn't a valid command." end if not minetest.check_player_privs(name, cmd.privs) then - return false, "Your privileges are insufficient to execute one or more commands in that list." + return false, "Your privileges are insufficient to execute /"..command_name..". Abort." end - + -- print("[DEBUG] command_name", command_name, "cmd", dump2(cmd)) minetest.log("action", name.." runs "..command) cmd.func(name, args) From 7774f8538c1dc47205762bbe905fadcf49565b27 Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Thu, 11 Mar 2021 02:05:11 +0000 Subject: [PATCH 2/2] Update changelog fixes #41 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e0999..1dbb20b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ Note to self: See the bottom of this file for the release template text. - Add `//srect` (_select rectangle_) - thanks, @VorTechnix! - Add `//spush`, `//spop`, and `//sstack` - `//overlay`: Don't place nodes above water + - `//multi`: Improve resilience by handling some edge cases ## v1.11: The big data update (25th January 2021)