Validate at least a valid context for the terminal.

This commit is contained in:
Auke Kok 2017-09-18 21:32:17 -07:00
parent 9db70c273f
commit a01fb5c7db

View File

@ -168,10 +168,17 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
if formname ~= "terminal:" then
return false
end
-- input validation
local name = player:get_player_name()
local c = context[name]
if not context[name] then
minetest.log("error", name .. " sends invalid formspec data")
return true
end
local line = fields.input
if line and line ~= "" then
local name = player:get_player_name()
local c = context[name]
local output = c.output or ""
minetest.sound_play("terminal_keyboard_clicks", {pos = c.pos})
@ -234,8 +241,6 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
minetest.show_formspec(name, "terminal:", make_formspec(output, "> "))
end
elseif fields.quit then
local name = player:get_player_name()
local c = context[name]
minetest.sound_play("terminal_power_off", {pos = c.pos})
end
return true