mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Chat: Validate UTF8 in chat messages
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "Util.h"
|
||||
#include "World.h"
|
||||
#include "WorldPacket.h"
|
||||
#include <utf8.h>
|
||||
#include <algorithm>
|
||||
|
||||
inline bool isNasty(uint8 c)
|
||||
@@ -258,6 +259,14 @@ void WorldSession::HandleMessagechatOpcode(WorldPacket& recvData)
|
||||
return;
|
||||
}
|
||||
|
||||
// validate utf8
|
||||
if (!utf8::is_valid(msg.begin(), msg.end()))
|
||||
{
|
||||
TC_LOG_ERROR("network", "Player %s (GUID: %u) sent a message containing an invalid UTF8 sequence - blocked", GetPlayer()->GetName().c_str(),
|
||||
GetPlayer()->GetGUID().GetCounter());
|
||||
return;
|
||||
}
|
||||
|
||||
// collapse multiple spaces into one
|
||||
if (sWorld->getBoolConfig(CONFIG_CHAT_FAKE_MESSAGE_PREVENTING))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user