Remove illegal characters in chat messages before sending (#1587)

Sending illegal character will cause server to kick the client. This happens when using remote control to execute some command that contains color output. Message checking applies to remote control only.
This commit is contained in:
ReinforceZwei 2021-05-13 01:34:55 +08:00 committed by GitHub
parent b15c3a8e46
commit 3b5488a7bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 0 deletions

View file

@ -19,6 +19,11 @@ namespace MinecraftClient.ChatBots
{
string response = "";
PerformInternalCommand(command, ref response);
response = GetVerbatim(response);
foreach (char disallowedChar in McClient.GetDisallowedChatCharacters())
{
response = response.Replace(disallowedChar.ToString(), String.Empty);
}
if (response.Length > 0)
{
SendPrivateMessage(sender, response);