aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubenwardy <rw@rubenwardy.com>2019-03-26 01:18:52 +0000
committerrubenwardy <rw@rubenwardy.com>2019-03-28 21:49:03 +0000
commitcf1802a6de51ec14c98b1424ba95e86a66cf7c75 (patch)
tree750b39493763ed0dbfe90800d5d956a34cd8f474
parent538a7b12bd0c5c10e0ef16dde363f16eb447c101 (diff)
downloadminetest-cf1802a6de51ec14c98b1424ba95e86a66cf7c75.tar.gz
minetest-cf1802a6de51ec14c98b1424ba95e86a66cf7c75.tar.bz2
minetest-cf1802a6de51ec14c98b1424ba95e86a66cf7c75.zip
Prevent multi-line chat messages server-side (#8420)
-rw-r--r--src/server.cpp7
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