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.
This commit is contained in:
Hannah Giovanna Dawson
2023-12-30 00:38:11 +00:00
committed by GitHub
parent 530e3c4add
commit 84f544ff10

View File

@@ -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;
@@ -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);