File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed
Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -478,6 +478,23 @@ void ServerLobby::handleChat(Event* event)
478478 core::stringw message;
479479 event->data ().decodeString16 (&message, 360 /* max_len*/ );
480480
481+ // Check if the message starts with "(the name of main profile): " to prevent
482+ // impersonation, see #5121.
483+ std::string message_utf8 = StringUtils::wideToUtf8 (message);
484+ std::string prefix = StringUtils::wideToUtf8 (
485+ event->getPeer ()->getPlayerProfiles ()[0 ]->getName ()) + " : " ;
486+
487+ if (!StringUtils::startsWith (message_utf8, prefix))
488+ {
489+ NetworkString* chat = getNetworkString ();
490+ chat->setSynchronous (true );
491+ core::stringw warn = " Don't try to impersonate others!" ;
492+ chat->addUInt8 (LE_CHAT).encodeString16 (warn);
493+ event->getPeer ()->sendPacket (chat, true /* reliable*/ );
494+ delete chat;
495+ return ;
496+ }
497+
481498 KartTeam target_team = KART_TEAM_NONE;
482499 if (event->data ().size () > 0 )
483500 target_team = (KartTeam)event->data ().getUInt8 ();
You can’t perform that action at this time.
0 commit comments