aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Handlers/GuildHandler.cpp48
-rw-r--r--src/server/game/Server/WorldSession.cpp14
-rw-r--r--src/server/game/Server/WorldSession.h3
3 files changed, 65 insertions, 0 deletions
diff --git a/src/server/game/Handlers/GuildHandler.cpp b/src/server/game/Handlers/GuildHandler.cpp
index fc8764dfeef..e0e44202c09 100644
--- a/src/server/game/Handlers/GuildHandler.cpp
+++ b/src/server/game/Handlers/GuildHandler.cpp
@@ -162,6 +162,12 @@ void WorldSession::HandleGuildMOTDOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_MOTD [%s]: MOTD: %s", GetPlayerInfo().c_str(), motd.c_str());
+ if (!DisallowHyperlinksAndMaybeKick(motd))
+ return;
+
+ if (motd.size() > 128)
+ return;
+
if (Guild* guild = GetPlayer()->GetGuild())
guild->HandleSetMOTD(this, motd);
}
@@ -175,6 +181,12 @@ void WorldSession::HandleGuildSetPublicNoteOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_SET_PUBLIC_NOTE [%s]: Target: %s, Note: %s",
GetPlayerInfo().c_str(), playerName.c_str(), note.c_str());
+ if (!DisallowHyperlinksAndMaybeKick(note))
+ return;
+
+ if (note.size() > 31)
+ return;
+
if (normalizePlayerName(playerName))
if (Guild* guild = GetPlayer()->GetGuild())
guild->HandleSetMemberNote(this, playerName, note, false);
@@ -189,6 +201,12 @@ void WorldSession::HandleGuildSetOfficerNoteOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_SET_OFFICER_NOTE [%s]: Target: %s, Note: %s",
GetPlayerInfo().c_str(), playerName.c_str(), note.c_str());
+ if (!DisallowHyperlinksAndMaybeKick(note))
+ return;
+
+ if (note.size() > 31)
+ return;
+
if (normalizePlayerName(playerName))
if (Guild* guild = GetPlayer()->GetGuild())
guild->HandleSetMemberNote(this, playerName, note, true);
@@ -210,6 +228,12 @@ void WorldSession::HandleGuildRankOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_RANK [%s]: Rank: %s (%u)", GetPlayerInfo().c_str(), rankName.c_str(), rankId);
+ if (!DisallowHyperlinksAndMaybeKick(rankName))
+ return;
+
+ if (rankName.size() > 15)
+ return;
+
Guild* guild = GetPlayer()->GetGuild();
if (!guild)
{
@@ -240,6 +264,12 @@ void WorldSession::HandleGuildAddRankOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_ADD_RANK [%s]: Rank: %s", GetPlayerInfo().c_str(), rankName.c_str());
+ if (!DisallowHyperlinksAndMaybeKick(rankName))
+ return;
+
+ if (rankName.size() > 15)
+ return;
+
if (Guild* guild = GetPlayer()->GetGuild())
guild->HandleAddNewRank(this, rankName);
}
@@ -259,6 +289,12 @@ void WorldSession::HandleGuildChangeInfoTextOpcode(WorldPacket& recvPacket)
TC_LOG_DEBUG("guild", "CMSG_GUILD_INFO_TEXT [%s]: %s", GetPlayerInfo().c_str(), info.c_str());
+ if (!DisallowHyperlinksAndMaybeKick(info))
+ return;
+
+ if (info.size() > 500)
+ return;
+
if (Guild* guild = GetPlayer()->GetGuild())
guild->HandleSetInfo(this, info);
}
@@ -485,6 +521,12 @@ void WorldSession::HandleGuildBankUpdateTab(WorldPacket& recvData)
recvData >> guid >> tabId >> name >> icon;
+ if (!DisallowHyperlinksAndMaybeKick(name))
+ return;
+
+ if ((name.size() > 16) || (icon.size() > 128))
+ return;
+
TC_LOG_DEBUG("guild", "CMSG_GUILD_BANK_UPDATE_TAB [%s]: [%s], TabId: %u, Name: %s, Icon: %s"
, GetPlayerInfo().c_str(), guid.ToString().c_str(), tabId, name.c_str(), icon.c_str());
@@ -522,6 +564,12 @@ void WorldSession::HandleSetGuildBankTabText(WorldPacket &recvData)
std::string text;
recvData >> tabId >> text;
+ if (!DisallowHyperlinksAndMaybeKick(text))
+ return;
+
+ if (text.size() > 500)
+ return;
+
TC_LOG_DEBUG("guild", "CMSG_SET_GUILD_BANK_TEXT [%s]: TabId: %u, Text: %s", GetPlayerInfo().c_str(), tabId, text.c_str());
if (Guild* guild = GetPlayer()->GetGuild())
diff --git a/src/server/game/Server/WorldSession.cpp b/src/server/game/Server/WorldSession.cpp
index 765efafd344..d38516491e4 100644
--- a/src/server/game/Server/WorldSession.cpp
+++ b/src/server/game/Server/WorldSession.cpp
@@ -619,6 +619,20 @@ bool WorldSession::ValidateHyperlinksAndMaybeKick(std::string const& str)
return false;
}
+bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string const& str)
+{
+ if (str.find('|') == std::string::npos)
+ return true;
+
+ TC_LOG_ERROR("network", "Player %s (GUID: %u) sent a message which illegally contained a hyperlink:\n%s", GetPlayer()->GetName().c_str(),
+ GetPlayer()->GetGUID().GetCounter(), str.c_str());
+
+ if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
+ KickPlayer();
+
+ return false;
+}
+
void WorldSession::SendNotification(const char *format, ...)
{
if (format)
diff --git a/src/server/game/Server/WorldSession.h b/src/server/game/Server/WorldSession.h
index 9edd5f28893..713d9172bbf 100644
--- a/src/server/game/Server/WorldSession.h
+++ b/src/server/game/Server/WorldSession.h
@@ -369,6 +369,9 @@ class TC_GAME_API WorldSession
// Returns true if all contained hyperlinks are valid
// May kick player on false depending on world config (handler should abort)
bool ValidateHyperlinksAndMaybeKick(std::string const& str);
+ // Returns true if the message contains no hyperlinks
+ // May kick player on false depending on world config (handler should abort)
+ bool DisallowHyperlinksAndMaybeKick(std::string const& str);
void QueuePacket(WorldPacket* new_packet);
bool Update(uint32 diff, PacketFilter& updater);