Limit chatcommand parameter length in command blocks (#695)

This commit is contained in:
luk3yx 2024-12-23 07:08:44 +13:00 committed by GitHub
parent 8051129f82
commit 320ec93544
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 0 deletions

View File

@ -1,4 +1,5 @@
local S = minetest.get_translator(minetest.get_current_modname())
local param_maxlen = mesecon.setting("commandblock_param_maxlen", 10000)
minetest.register_chatcommand("say", {
params = "<text>",
@ -156,6 +157,11 @@ local function commandblock_action_on(pos, node)
minetest.chat_send_player(owner, "The command "..cmd.." does not exist")
return
end
if #param > param_maxlen then
minetest.chat_send_player(owner, "Command parameters are limited to max. " ..
param_maxlen .. " bytes.")
return
end
local has_privs, missing_privs = minetest.check_player_privs(owner, cmddef.privs)
if not has_privs then
minetest.chat_send_player(owner, "You don't have permission "

View File

@ -11,6 +11,11 @@ mesecon.cooldown_granularity (Cooldown step length) float 0.5 0.0 1.0
mesecon.blinky_plant_interval (Plant blinking interval) int 3 1 5
[mesecons_commandblock]
mesecon.commandblock_param_maxlen (Maximum command parameter length) int 10000 100 1000000
[mesecons_detector]
mesecon.detector_radius (Player detector scanning radius) int 6 3 16