diff --git a/Client/mods/deathmatch/logic/CPacketHandler.cpp b/Client/mods/deathmatch/logic/CPacketHandler.cpp index 675a9b72966..054750b525c 100644 --- a/Client/mods/deathmatch/logic/CPacketHandler.cpp +++ b/Client/mods/deathmatch/logic/CPacketHandler.cpp @@ -1412,7 +1412,8 @@ void CPacketHandler::Packet_ChatEcho(NetBitStreamInterface& bitStream) bitStream.Read(szMessage, iNumberOfBytesUsed); szMessage[iNumberOfBytesUsed] = 0; // actual limits enforced on the remote client, this is the maximum a string can be to be printed. - if (MbUTF8ToUTF16(szMessage).size() <= + SString textToProcess = bColorCoded ? RemoveColorCodes(szMessage) : szMessage; + if (MbUTF8ToUTF16(textToProcess).size() <= MAX_CHATECHO_LENGTH + 6) // Extra 6 characters to fix #7125 (Teamsay + long name + long message = too long message) { // Strip it for bad characters diff --git a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 9e8bf4e3e2f..544d0ad26aa 100644 --- a/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -260,21 +260,27 @@ bool CStaticFunctionDefinitions::ClearChatBox() bool CStaticFunctionDefinitions::OutputChatBox(const char* szText, unsigned char ucRed, unsigned char ucGreen, unsigned char ucBlue, bool bColorCoded) { - if (strlen(szText) <= MAX_OUTPUTCHATBOX_LENGTH) - { - CLuaArguments Arguments; - Arguments.PushString(szText); - Arguments.PushNumber(ucRed); - Arguments.PushNumber(ucGreen); - Arguments.PushNumber(ucBlue); + if (!szText || szText[0] == '\0') + return false; + + SString textToProcess = bColorCoded ? RemoveColorCodes(szText) : szText; + + if (textToProcess.length() > MAX_OUTPUTCHATBOX_LENGTH) { + return false; + } - bool bCancelled = !g_pClientGame->GetRootEntity()->CallEvent("onClientChatMessage", Arguments, false); - if (!bCancelled) - { - m_pCore->ChatPrintfColor("%s", bColorCoded, ucRed, ucGreen, ucBlue, szText); - return true; - } + CLuaArguments Arguments; + Arguments.PushString(szText); + Arguments.PushNumber(ucRed); + Arguments.PushNumber(ucGreen); + Arguments.PushNumber(ucBlue); + + bool bCancelled = !g_pClientGame->GetRootEntity()->CallEvent("onClientChatMessage", Arguments, false); + if (!bCancelled) { + m_pCore->ChatPrintfColor("%s", bColorCoded, ucRed, ucGreen, ucBlue, szText); + return true; } + return false; }