From d577ee485ed5d1f016c90436a623ea8940a46503 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+electrojr@users.noreply.github.com> Date: Fri, 31 May 2024 23:05:34 +0300 Subject: [PATCH] Make chat & examine systems use FormattedMessage.EscapeText() (#28431) (cherry picked from commit c4291920a628a13684769f54adc4b0df7b7b09ad) --- Content.Client/Examine/ExamineSystem.cs | 6 ++---- Content.Server/Chat/Systems/ChatSystem.cs | 4 ++-- Content.Shared/Chat/MsgChatMessage.cs | 11 +++++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Content.Client/Examine/ExamineSystem.cs b/Content.Client/Examine/ExamineSystem.cs index 38a6bc8692..fb145d544e 100644 --- a/Content.Client/Examine/ExamineSystem.cs +++ b/Content.Client/Examine/ExamineSystem.cs @@ -239,9 +239,7 @@ namespace Content.Client.Examine if (knowTarget) { - // TODO: FormattedMessage.RemoveMarkupPermissive - // var itemName = FormattedMessage.RemoveMarkupPermissive(Identity.Name(target, EntityManager, player)); - var itemName = FormattedMessage.FromMarkupPermissive(Identity.Name(target, EntityManager, player)).ToString(); + var itemName = FormattedMessage.EscapeText(Identity.Name(target, EntityManager, player)); var labelMessage = FormattedMessage.FromMarkupPermissive($"[bold]{itemName}[/bold]"); var label = new RichTextLabel(); label.SetMessage(labelMessage); @@ -250,7 +248,7 @@ namespace Content.Client.Examine else { var label = new RichTextLabel(); - label.SetMessage(FormattedMessage.FromMarkup("[bold]???[/bold]")); + label.SetMessage(FormattedMessage.FromMarkupOrThrow("[bold]???[/bold]")); hBox.AddChild(label); } diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index 8bdbcd8beb..8ba4c15020 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -422,7 +422,7 @@ public sealed partial class ChatSystem : SharedChatSystem return; // The original message - var message = TransformSpeech(source, FormattedMessage.RemoveMarkupPermissive(originalMessage), language); + var message = TransformSpeech(source, originalMessage, language); if (message.Length == 0) return; @@ -460,7 +460,7 @@ public sealed partial class ChatSystem : SharedChatSystem // To avoid logging any messages sent by entities that are not players, like vendors, cloning, etc. // Also doesn't log if hideLog is true. - if (!HasComp(source) || hideLog == true) + if (!HasComp(source) || hideLog) return; if (originalMessage == message) diff --git a/Content.Shared/Chat/MsgChatMessage.cs b/Content.Shared/Chat/MsgChatMessage.cs index 056caff6f1..84d2c4158c 100644 --- a/Content.Shared/Chat/MsgChatMessage.cs +++ b/Content.Shared/Chat/MsgChatMessage.cs @@ -11,8 +11,19 @@ namespace Content.Shared.Chat public sealed class ChatMessage { public ChatChannel Channel; + + /// + /// This is the text spoken by the entity, after accents and such were applied. + /// This should have applied before using it in any rich text box. + /// public string Message; + + /// + /// This is the but with special characters escaped and wrapped in some rich text + /// formatting tags. + /// public string WrappedMessage; + public NetEntity SenderEntity; ///