From a824bbb8f3022bd183145ffdc6049bb0c2ab0d64 Mon Sep 17 00:00:00 2001 From: luk3yx Date: Thu, 15 Nov 2018 09:01:12 +1300 Subject: [PATCH] =?UTF-8?q?Security=20fix.=20=20=E2=80=A2=20Make=20it=20mo?= =?UTF-8?q?re=20clear=20when=20players=20use=20newlines=20in=20a=20message?= =?UTF-8?q?.=20=20=E2=80=A2=20Stop=20overriding=20.list=5Fplayers.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- init.lua | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/init.lua b/init.lua index b690601..d1c259b 100644 --- a/init.lua +++ b/init.lua @@ -218,9 +218,15 @@ chat_channels.display_without_colours = function(msg) end end +local strip_newlines = function(msg) + local msg, c = msg:gsub('\n', '\n --- ') + return msg +end + minetest.register_on_receiving_chat_messages(function(msg) local m = minetest.strip_colors(msg) if strip_colours then msg = m end + msg = strip_newlines(msg) if m == 'Message sent.' or m:match('^The player .* is not online.$') or m:match('^Your PM has been sent to') then if messages_sent > 0 then @@ -305,7 +311,7 @@ minetest.register_on_receiving_chat_messages(function(msg) end end - return chat_channels.display_without_colours(msg) + return chat_channels.display_without_colours(m) end) minetest.register_chatcommand('add_to_channel', { @@ -494,18 +500,3 @@ if true then minetest.register_chatcommand('strip_colors', def) end - --- Override .list_players to make it display all players, not just players --- visible to the client. -minetest.override_chatcommand('list_players', { - func = function() - local p = {localplayer} - for player, _ in pairs(connected_players) do - if player ~= localplayer and _ then - table.insert(p, player) - end - end - table.sort(p) - return true, "Online players: " .. table.concat(p, ', ') - end -})