Core/Chat: Validate UTF8 in chat messages

(cherry picked from commit e5d63bc5b0)
This commit is contained in:
Treeston
2018-09-18 17:11:25 +02:00
committed by Shauren
parent b321d05386
commit f4ae292123

View File

@@ -41,6 +41,7 @@
#include "Util.h"
#include "World.h"
#include "WorldPacket.h"
#include <utf8.h>
#include <algorithm>
inline bool isNasty(uint8 c)
@@ -72,6 +73,14 @@ inline bool ValidateMessage(Player const* player, std::string& msg)
}
}
// validate utf8
if (!utf8::is_valid(msg.begin(), msg.end()))
{
TC_LOG_ERROR("network", "Player %s (%s) sent a message containing an invalid UTF8 sequence - blocked", player->GetName().c_str(),
player->GetGUID().ToString().c_str());
return;
}
// collapse multiple spaces into one
if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
{