Sanitize shorthand emotes throughought the whole message (#28645)

* Rename ChatSanitizationManager to ChatEmoteSanitizationManager

The prior name was kind of confusing as there's a emote one and
then now there's also chat expansion happening in the accent system,
so knowing which I actually need to edit is useful.

So, I just need to keep myself not confused.

* Rename smileyToEmote and remove punctuation duplicates

The name SmileyToEmote is just... Bad.

Plus, I needed to remove the punctuation duplicates as that would
break any kind of regex parsing that I tried.

* Switch to regex from checking end of string

I also changed from System.Globalization to ILocalizationManager.

Writing that regex was definitely an experience.

* Document regex and the manager

* Rename it back

* Simplify regex
This commit is contained in:
Thomas
2024-10-17 09:01:32 -05:00
committed by GitHub
parent ea96e8a1cf
commit 876c44cd66
3 changed files with 72 additions and 32 deletions

View File

@@ -749,6 +749,9 @@ public sealed partial class ChatSystem : SharedChatSystem
var newMessage = message.Trim();
newMessage = SanitizeMessageReplaceWords(newMessage);
// Sanitize it first as it might change the word order
_sanitizer.TrySanitizeEmoteShorthands(newMessage, source, out newMessage, out emoteStr);
if (capitalize)
newMessage = SanitizeMessageCapital(newMessage);
if (capitalizeTheWordI)
@@ -756,8 +759,6 @@ public sealed partial class ChatSystem : SharedChatSystem
if (punctuate)
newMessage = SanitizeMessagePeriod(newMessage);
_sanitizer.TrySanitizeOutSmilies(newMessage, source, out newMessage, out emoteStr);
return newMessage;
}