diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2018-09-13 00:11:27 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-10-31 01:39:04 +0200 |
| commit | e506c80a64571530cf7edd947a5b7dc2f35f9d1d (patch) | |
| tree | e78a0d480537525c9db0b8ebb9d08f6ce8bdcc6e /src/server/game/Chat/Chat.cpp | |
| parent | fa7e46a4f3f807b0682aba26c7993d142f842648 (diff) | |
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)
Diffstat (limited to 'src/server/game/Chat/Chat.cpp')
| -rw-r--r-- | src/server/game/Chat/Chat.cpp | 62 |
1 files changed, 1 insertions, 61 deletions
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 <boost/algorithm/string/replace.hpp> +#include <sstream> // 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<ChatCommand> const& table, char const* cmd, char const* subcmd) { std::string list; |
