Core/Chat: Fixed chat channel name validation
Port From (https://github.com/TrinityCore/TrinityCore/commit/cf525beefd3c12e07b0883963806f202a6daff60)
This commit is contained in:
@@ -41,7 +41,19 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
if (packet.ChannelName.IsEmpty() || char.IsDigit(packet.ChannelName[0]))
|
||||
ChannelManager cMgr = ChannelManager.ForTeam(GetPlayer().GetTeam());
|
||||
if (cMgr == null)
|
||||
return;
|
||||
|
||||
if (packet.ChatChannelId != 0)
|
||||
{ // system channel
|
||||
Channel channel = cMgr.GetSystemChannel((uint)packet.ChatChannelId, zone);
|
||||
if (channel != null)
|
||||
channel.JoinChannel(GetPlayer());
|
||||
}
|
||||
else
|
||||
{ // custom channel
|
||||
if (packet.ChannelName.IsEmpty() || Char.IsDigit(packet.ChannelName[0]))
|
||||
{
|
||||
ChannelNotify channelNotify = new();
|
||||
channelNotify.Type = ChatNotify.InvalidNameNotice;
|
||||
@@ -52,28 +64,11 @@ namespace Game
|
||||
|
||||
if (packet.Password.Length > 127)
|
||||
{
|
||||
Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a password more than 127 characters long - blocked");
|
||||
Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a password more than {127} characters long - blocked");
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelManager cMgr = ChannelManager.ForTeam(GetPlayer().GetTeam());
|
||||
if (cMgr != null)
|
||||
{
|
||||
if (packet.ChatChannelId != 0)
|
||||
{
|
||||
// system channel
|
||||
Channel channel = cMgr.GetSystemChannel((uint)packet.ChatChannelId, zone);
|
||||
if (channel != null)
|
||||
channel.JoinChannel(GetPlayer());
|
||||
}
|
||||
else
|
||||
{
|
||||
// custom channel
|
||||
if (packet.ChannelName.Length > 31)
|
||||
{
|
||||
Log.outError(LogFilter.Network, $"Player {GetPlayer().GetGUID()} tried to create a channel with a name more than 31 characters long - blocked");
|
||||
if (!DisallowHyperlinksAndMaybeKick(packet.ChannelName))
|
||||
return;
|
||||
}
|
||||
|
||||
Channel channel = cMgr.GetCustomChannel(packet.ChannelName);
|
||||
if (channel != null)
|
||||
@@ -89,7 +84,6 @@ namespace Game
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.ChatLeaveChannel)]
|
||||
void HandleLeaveChannel(LeaveChannel packet)
|
||||
|
||||
Reference in New Issue
Block a user