From: Hannah Giovanna Dawson Date: Sat, 30 Dec 2023 00:38:11 +0000 (+0000) Subject: Clean out tags when attempting to speak/whisper/emote (#23055) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=84f544ff103d038c33309494c4bbc4cd9698839a;p=space-station-14.git Clean out tags when attempting to speak/whisper/emote (#23055) A few bugs have popped up where (legal) string formatting tags have been duplicated out into whisper and local. Using the RemoveMarkup static we can sanitize attempted speech to remove markup. --- diff --git a/Content.Server/Chat/Systems/ChatSystem.cs b/Content.Server/Chat/Systems/ChatSystem.cs index c8a43bb3a6..2ca1404bc5 100644 --- a/Content.Server/Chat/Systems/ChatSystem.cs +++ b/Content.Server/Chat/Systems/ChatSystem.cs @@ -384,7 +384,8 @@ public sealed partial class ChatSystem : SharedChatSystem if (!_actionBlocker.CanSpeak(source) && !ignoreActionBlocker) return; - var message = TransformSpeech(source, originalMessage); + var message = TransformSpeech(source, FormattedMessage.RemoveMarkup(originalMessage)); + if (message.Length == 0) return; @@ -416,7 +417,7 @@ public sealed partial class ChatSystem : SharedChatSystem RaiseLocalEvent(source, ev, true); // To avoid logging any messages sent by entities that are not players, like vendors, cloning, etc. - // Also doesn't log if hideLog is true. + // Also doesn't log if hideLog is true. if (!HasComp(source) || hideLog == true) return; @@ -451,7 +452,7 @@ public sealed partial class ChatSystem : SharedChatSystem if (!_actionBlocker.CanSpeak(source) && !ignoreActionBlocker) return; - var message = TransformSpeech(source, originalMessage); + var message = TransformSpeech(source, FormattedMessage.RemoveMarkup(originalMessage)); if (message.Length == 0) return; @@ -473,7 +474,6 @@ public sealed partial class ChatSystem : SharedChatSystem } name = FormattedMessage.EscapeText(name); - var wrappedMessage = Loc.GetString("chat-manager-entity-whisper-wrap-message", ("entityName", name), ("message", FormattedMessage.EscapeText(message))); @@ -551,7 +551,7 @@ public sealed partial class ChatSystem : SharedChatSystem var wrappedMessage = Loc.GetString("chat-manager-entity-me-wrap-message", ("entityName", name), ("entity", ent), - ("message", FormattedMessage.EscapeText(action))); + ("message", FormattedMessage.RemoveMarkup(action))); if (checkEmote) TryEmoteChatInput(source, action); @@ -614,7 +614,8 @@ public sealed partial class ChatSystem : SharedChatSystem #region Utility - private enum MessageRangeCheckResult { + private enum MessageRangeCheckResult + { Disallowed, HideChat, Full @@ -797,7 +798,7 @@ public sealed partial class ChatSystem : SharedChatSystem foreach (var player in _playerManager.Sessions) { - if (player.AttachedEntity is not {Valid: true} playerEntity) + if (player.AttachedEntity is not { Valid: true } playerEntity) continue; var transformEntity = xforms.GetComponent(playerEntity);