mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-15 01:59:09 +00:00
feat(Core/Chat): new argument parsing and unify chat hyperlink parsing (#6243)
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "Group.h"
|
||||
#include "Guild.h"
|
||||
#include "GuildMgr.h"
|
||||
#include "Hyperlinks.h"
|
||||
#include "Log.h"
|
||||
#include "MapMgr.h"
|
||||
#include "ObjectAccessor.h"
|
||||
@@ -389,6 +390,26 @@ bool WorldSession::Update(uint32 diff, PacketFilter& updater)
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (WorldPackets::InvalidHyperlinkException const& ihe)
|
||||
{
|
||||
LOG_ERROR("network", "%s sent %s with an invalid link:\n%s", GetPlayerInfo().c_str(),
|
||||
GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), ihe.GetInvalidValue().c_str());
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
|
||||
{
|
||||
KickPlayer("WorldSession::Update Invalid chat link");
|
||||
}
|
||||
}
|
||||
catch (WorldPackets::IllegalHyperlinkException const& ihe)
|
||||
{
|
||||
LOG_ERROR("network", "%s sent %s which illegally contained a hyperlink:\n%s", GetPlayerInfo().c_str(),
|
||||
GetOpcodeNameForLogging(static_cast<OpcodeClient>(packet->GetOpcode())).c_str(), ihe.GetInvalidValue().c_str());
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
|
||||
{
|
||||
KickPlayer("WorldSession::Update Illegal chat link");
|
||||
}
|
||||
}
|
||||
catch (WorldPackets::PacketArrayMaxCapacityException const& pamce)
|
||||
{
|
||||
LOG_ERROR("network", "PacketArrayMaxCapacityException: %s while parsing %s from %s.",
|
||||
@@ -698,6 +719,34 @@ void WorldSession::KickPlayer(std::string const& reason, bool setKicked)
|
||||
SetKicked(true); // pussywizard: the session won't be left ingame for 60 seconds and to also kick offline session
|
||||
}
|
||||
|
||||
bool WorldSession::ValidateHyperlinksAndMaybeKick(std::string_view str)
|
||||
{
|
||||
if (Acore::Hyperlinks::CheckAllLinks(str))
|
||||
return true;
|
||||
|
||||
LOG_ERROR("network", "Player %s%s sent a message with an invalid link:\n%.*s", GetPlayer()->GetName().c_str(),
|
||||
GetPlayer()->GetGUID().ToString().c_str(), STRING_VIEW_FMT_ARG(str));
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
|
||||
KickPlayer("WorldSession::ValidateHyperlinksAndMaybeKick Invalid chat link");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool WorldSession::DisallowHyperlinksAndMaybeKick(std::string_view str)
|
||||
{
|
||||
if (str.find('|') == std::string_view::npos)
|
||||
return true;
|
||||
|
||||
LOG_ERROR("network", "Player %s %s sent a message which illegally contained a hyperlink:\n%.*s", GetPlayer()->GetName().c_str(),
|
||||
GetPlayer()->GetGUID().ToString().c_str(), STRING_VIEW_FMT_ARG(str));
|
||||
|
||||
if (sWorld->getIntConfig(CONFIG_CHAT_STRICT_LINK_CHECKING_KICK))
|
||||
KickPlayer("WorldSession::DisallowHyperlinksAndMaybeKick Illegal chat link");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void WorldSession::SendNotification(const char* format, ...)
|
||||
{
|
||||
if (format)
|
||||
|
||||
Reference in New Issue
Block a user