Security fix

This commit is contained in:
Athozus 2023-03-31 18:07:23 +02:00
parent b083f484c0
commit 11b4fe17b6
No known key found for this signature in database
GPG key ID: B50895022E8484BF

View file

@ -1,5 +1,5 @@
local FORMNAME = "mail:compose" local FORMNAME = "mail:compose"
local msg_id = nil local msg_id = {}
function mail.show_compose(name, to, subject, body, cc, bcc, id) function mail.show_compose(name, to, subject, body, cc, bcc, id)
local formspec = [[ local formspec = [[
@ -25,7 +25,7 @@ function mail.show_compose(name, to, subject, body, cc, bcc, id)
minetest.formspec_escape(body) or "") minetest.formspec_escape(body) or "")
if id then if id then
msg_id = id msg_id[name] = id
end end
minetest.show_formspec(name, FORMNAME, formspec) minetest.show_formspec(name, FORMNAME, formspec)
@ -39,8 +39,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
local name = player:get_player_name() local name = player:get_player_name()
if fields.send then if fields.send then
local id = mail.new_uuid() local id = mail.new_uuid()
if msg_id then if msg_id[name] then
id = msg_id id = msg_id[name]
end end
local success, err = mail.send({ local success, err = mail.send({
id = id, id = id,
@ -97,8 +97,8 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
elseif fields.draft then elseif fields.draft then
local id = mail.new_uuid() local id = mail.new_uuid()
if msg_id then if msg_id[name] then
id = msg_id id = msg_id[name]
end end
mail.save_draft({ mail.save_draft({
id = id, id = id,