1
0
mirror of https://github.com/minetest/minetest_game.git synced 2025-07-06 00:10:20 +02:00

Validate & sanitize formspec fields

This commit is contained in:
Lars Mueller
2023-03-30 21:11:59 +02:00
parent 8eb4437ac8
commit 8ccce750c6
4 changed files with 16 additions and 9 deletions

View File

@ -2597,12 +2597,12 @@ local function register_sign(material, desc, def)
if not text then
return
end
if string.len(text) > 512 then
if #text > 512 then
minetest.chat_send_player(player_name, S("Text too long"))
return
end
default.log_player_action(sender, "wrote \"" .. text ..
"\" to the sign at", pos)
text = text:gsub("[%z-\8\11-\31\127]", "") -- strip naughty control characters (keeps \t and \n)
default.log_player_action(sender, ("wrote %q to the sign at"):format(text), pos)
local meta = minetest.get_meta(pos)
meta:set_string("text", text)