mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2025-10-15 23:25:39 +02:00
Check empty command parameters strictly
This commit is contained in:
@@ -51,6 +51,7 @@ local function chatcommand_handler(cmd_name, name, param)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
param = param:trim()
|
||||||
local parsed = {def.parse(param)}
|
local parsed = {def.parse(param)}
|
||||||
local success = table.remove(parsed, 1)
|
local success = table.remove(parsed, 1)
|
||||||
if not success then
|
if not success then
|
||||||
@@ -116,8 +117,9 @@ function worldedit.register_command(name, def)
|
|||||||
def.require_pos = def.require_pos or 0
|
def.require_pos = def.require_pos or 0
|
||||||
assert(def.require_pos >= 0 and def.require_pos < 3)
|
assert(def.require_pos >= 0 and def.require_pos < 3)
|
||||||
if def.params == "" and not def.parse then
|
if def.params == "" and not def.parse then
|
||||||
-- FIXME: shouldn't this check for param to be empty?
|
def.parse = function(param)
|
||||||
def.parse = function(param) return true end
|
return param == ""
|
||||||
|
end
|
||||||
else
|
else
|
||||||
assert(def.parse)
|
assert(def.parse)
|
||||||
end
|
end
|
||||||
|
@@ -34,7 +34,7 @@ local description_cache = nil
|
|||||||
|
|
||||||
-- normalizes node "description" `nodename`, returning a string (or nil)
|
-- normalizes node "description" `nodename`, returning a string (or nil)
|
||||||
worldedit.normalize_nodename = function(nodename)
|
worldedit.normalize_nodename = function(nodename)
|
||||||
nodename = nodename:gsub("^%s*(.-)%s*$", "%1") -- strip spaces
|
nodename = nodename:trim()
|
||||||
if nodename == "" then
|
if nodename == "" then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user