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

Prevent multi-line chat messages server-side (#8420)

This commit is contained in:
rubenwardy
2019-03-26 01:18:52 +00:00
committed by GitHub
parent 38ea0890ec
commit d0a1a29ab3

View File

@ -2874,8 +2874,13 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna
L"It was refused. Send a shorter message"; L"It was refused. Send a shorter message";
} }
auto message = trim(wide_to_utf8(wmessage));
if (message.find_first_of("\n\r") != std::wstring::npos) {
return L"New lines are not permitted in chat messages";
}
// Run script hook, exit if script ate the chat message // Run script hook, exit if script ate the chat message
if (m_script->on_chat_message(name, wide_to_utf8(wmessage))) if (m_script->on_chat_message(name, message))
return L""; return L"";
// Line to send // Line to send