diff options
author | rubenwardy <rw@rubenwardy.com> | 2019-03-26 01:18:52 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-26 01:18:52 +0000 |
commit | d0a1a29ab36196a73d5454f8de368ddbf8f957e4 (patch) | |
tree | 8a9e515adb685a2caabc608fdcd479fbc624417a /src | |
parent | 38ea0890ec76814188aea032ef527c7a2911e392 (diff) | |
download | minetest-d0a1a29ab36196a73d5454f8de368ddbf8f957e4.tar.gz minetest-d0a1a29ab36196a73d5454f8de368ddbf8f957e4.tar.bz2 minetest-d0a1a29ab36196a73d5454f8de368ddbf8f957e4.zip |
Prevent multi-line chat messages server-side (#8420)
Diffstat (limited to 'src')
-rw-r--r-- | src/server.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp index 003ad45b4..172bb4744 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2874,8 +2874,13 @@ std::wstring Server::handleChat(const std::string &name, const std::wstring &wna 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 - if (m_script->on_chat_message(name, wide_to_utf8(wmessage))) + if (m_script->on_chat_message(name, message)) return L""; // Line to send |