]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make chat & examine systems use FormattedMessage.EscapeText() (#28431)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 31 May 2024 20:05:34 +0000 (08:05 +1200)
committerGitHub <noreply@github.com>
Fri, 31 May 2024 20:05:34 +0000 (16:05 -0400)
Content.Client/Examine/ExamineSystem.cs
Content.Server/Chat/Systems/ChatSystem.cs
Content.Shared/Chat/MsgChatMessage.cs

index 125ec62e492058282e5f225eb1f2f45be94b9ae3..b476971a13aceb8c28cd239f42c817b9dc71c281 100644 (file)
@@ -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);
             }
 
index 111e56a2a35a2d7f669fdd80e383f1ea6ec6baab..8e6c2ba4b37c2c898ed6f2aaa15b6027c6364929 100644 (file)
@@ -378,7 +378,7 @@ public sealed partial class ChatSystem : SharedChatSystem
         if (!_actionBlocker.CanSpeak(source) && !ignoreActionBlocker)
             return;
 
-        var message = TransformSpeech(source, FormattedMessage.RemoveMarkup(originalMessage));
+        var message = TransformSpeech(source, originalMessage);
 
         if (message.Length == 0)
             return;
@@ -417,7 +417,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<ActorComponent>(source) || hideLog == true)
+        if (!HasComp<ActorComponent>(source) || hideLog)
             return;
 
         if (originalMessage == message)
index f7311d2dc8ceffbcaf92effe35862748ed1b345f..85367ffb739ade4a11a9d96f8dbef4835f5ec8d1 100644 (file)
@@ -11,8 +11,19 @@ namespace Content.Shared.Chat
     public sealed class ChatMessage
     {
         public ChatChannel Channel;
+
+        /// <summary>
+        /// This is the text spoken by the entity, after accents and such were applied.
+        /// This should have <see cref="FormattedMessage.EscapeText"/> applied before using it in any rich text box.
+        /// </summary>
         public string Message;
+
+        /// <summary>
+        /// This is the <see cref="Message"/> but with special characters escaped and wrapped in some rich text
+        /// formatting tags.
+        /// </summary>
         public string WrappedMessage;
+
         public NetEntity SenderEntity;
 
         /// <summary>