Fix chat sanitization and entity name escaping (#12015)

This commit is contained in:
Leon Friedrich
2022-10-18 19:59:09 +13:00
committed by GitHub
parent 6db886773b
commit 3aeba9a63e
11 changed files with 104 additions and 94 deletions

View File

@@ -6,6 +6,7 @@ using Content.Shared.Radio;
using Robust.Server.GameObjects;
using Robust.Shared.Network;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Set;
using Robust.Shared.Utility;
namespace Content.Server.Ghost.Components
{
@@ -37,12 +38,14 @@ namespace Content.Server.Ghost.Components
name = Identity.Name(speaker, _entMan);
}
message = FormattedMessage.EscapeText(message);
name = FormattedMessage.EscapeText(name);
var msg = new MsgChatMessage
{
Channel = ChatChannel.Radio,
Message = message,
//Square brackets are added here to avoid issues with escaping
MessageWrap = Loc.GetString("chat-radio-message-wrap", ("color", channel.Color), ("channel", $"\\[{channel.LocalizedName}\\]"), ("name", name))
WrappedMessage = Loc.GetString("chat-radio-message-wrap", ("color", channel.Color), ("channel", $"\\[{channel.LocalizedName}\\]"), ("name", name), ("message", message))
};
_netManager.ServerSendMessage(msg, playerChannel);