From e506c80a64571530cf7edd947a5b7dc2f35f9d1d Mon Sep 17 00:00:00 2001 From: Treeston Date: Thu, 13 Sep 2018 00:11:27 +0200 Subject: Core/Chat: Unify chat hyperlink parsing (PR #22417) - Validate most link properties all the time - If enabled, also validate link text (needs locale) - Instead of blocking the entire message, sanitize it - Apply filtering to DND/AFK messages. Closes #22399 (cherry picked from commit f27284594b18000a1c098262728fb19fdc63fc6c) --- src/server/game/Chat/Chat.cpp | 62 +------------------------------------------ 1 file changed, 1 insertion(+), 61 deletions(-) (limited to 'src/server/game/Chat/Chat.cpp') diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 2d180a6b1b9..434dbb67d1e 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -19,7 +19,6 @@ #include "AccountMgr.h" #include "CellImpl.h" #include "CharacterCache.h" -#include "ChatLink.h" #include "ChatPackets.h" #include "Common.h" #include "DatabaseEnv.h" @@ -37,6 +36,7 @@ #include "World.h" #include "WorldSession.h" #include +#include // Lazy loading of the command table cache from commands and the // ScriptMgr should be thread safe since the player commands, @@ -445,66 +445,6 @@ bool ChatHandler::ParseCommands(char const* text) return _ParseCommands(text+1); } -bool ChatHandler::isValidChatMessage(char const* message) -{ -/* -Valid examples: -|cffa335ee|Hitem:812:0:0:0:0:0:0:0:70|h[Glowing Brightwood Staff]|h|r -|cffffff00|Hquest:51101:-1:110:120:5|h[The Wounded King]|h|r -|cffffd000|Htrade:4037:1:150:1:6AAAAAAAAAAAAAAAAAAAAAAOAADAAAAAAAAAAAAAAAAIAAAAAAAAA|h[Engineering]|h|r -|cff4e96f7|Htalent:2232:-1|h[Taste for Blood]|h|r -|cff71d5ff|Hspell:21563|h[Command]|h|r -|cffffd000|Henchant:3919|h[Engineering: Rough Dynamite]|h|r -|cffffff00|Hachievement:546:0000000000000001:0:0:0:-1:0:0:0:0|h[Safe Deposit]|h|r -|cff66bbff|Hglyph:21:762|h[Glyph of Bladestorm]|h|r - -| will be escaped to || -*/ - - if (strlen(message) > 255) - return false; - - // more simple checks - if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) < 3) - { - const char validSequence[6] = "cHhhr"; - const char* validSequenceIterator = validSequence; - const std::string validCommands = "cHhr|"; - - while (*message) - { - // find next pipe command - message = strchr(message, '|'); - - if (!message) - return true; - - ++message; - char commandChar = *message; - if (validCommands.find(commandChar) == std::string::npos) - return false; - - ++message; - // validate sequence - if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_SEVERITY) == 2) - { - if (commandChar == *validSequenceIterator) - { - if (validSequenceIterator == validSequence + 4) - validSequenceIterator = validSequence; - else - ++validSequenceIterator; - } - else - return false; - } - } - return true; - } - - return LinkExtractor(message).IsValidMessage(); -} - bool ChatHandler::ShowHelpForSubCommands(std::vector const& table, char const* cmd, char const* subcmd) { std::string list; -- cgit v1.2.3