1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2025-10-15 15:15:45 +02:00

Check empty command parameters strictly

This commit is contained in:
sfan5
2025-09-24 21:29:39 +02:00
parent 9670a6d4e0
commit 08ab19fcbb
2 changed files with 5 additions and 3 deletions

View File

@@ -51,6 +51,7 @@ local function chatcommand_handler(cmd_name, name, param)
end
end
param = param:trim()
local parsed = {def.parse(param)}
local success = table.remove(parsed, 1)
if not success then
@@ -116,8 +117,9 @@ function worldedit.register_command(name, def)
def.require_pos = def.require_pos or 0
assert(def.require_pos >= 0 and def.require_pos < 3)
if def.params == "" and not def.parse then
-- FIXME: shouldn't this check for param to be empty?
def.parse = function(param) return true end
def.parse = function(param)
return param == ""
end
else
assert(def.parse)
end

View File

@@ -34,7 +34,7 @@ local description_cache = nil
-- normalizes node "description" `nodename`, returning a string (or nil)
worldedit.normalize_nodename = function(nodename)
nodename = nodename:gsub("^%s*(.-)%s*$", "%1") -- strip spaces
nodename = nodename:trim()
if nodename == "" then
return nil
end