]> git.lizzy.rs Git - minetest.git/commitdiff
Prevent multi-line chat messages server-side (#8420)
authorrubenwardy <rw@rubenwardy.com>
Tue, 26 Mar 2019 01:18:52 +0000 (01:18 +0000)
committerrubenwardy <rw@rubenwardy.com>
Thu, 28 Mar 2019 21:49:03 +0000 (21:49 +0000)
src/server.cpp

index 003ad45b42137989ffde8ab3a554387a25f7d9ed..172bb474447c6f461eefc989138c1ef7b96aaf79 100644 (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";
        }
 
+       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