Fix Emote Chat Sanitizer (#32940)
* Fix bug? * Fix :) * aaaa * AAAA!!! * comment * Nicer code * What's a pull requestWhat's a pull request?
This commit is contained in:
@@ -84,6 +84,35 @@ public abstract class SharedChatSystem : EntitySystem
|
||||
return current ?? _prototypeManager.Index<SpeechVerbPrototype>(speech.SpeechVerb);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits the input message into a radio prefix part and the rest to preserve it during sanitization.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is primarily for the chat emote sanitizer, which can match against ":b" as an emote, which is a valid radio keycode.
|
||||
/// </remarks>
|
||||
public void GetRadioKeycodePrefix(EntityUid source,
|
||||
string input,
|
||||
out string output,
|
||||
out string prefix)
|
||||
{
|
||||
prefix = string.Empty;
|
||||
output = input;
|
||||
|
||||
// If the string is less than 2, then it's probably supposed to be an emote.
|
||||
// No one is sending empty radio messages!
|
||||
if (input.Length <= 2)
|
||||
return;
|
||||
|
||||
if (!(input.StartsWith(RadioChannelPrefix) || input.StartsWith(RadioChannelAltPrefix)))
|
||||
return;
|
||||
|
||||
if (!_keyCodes.TryGetValue(input[1], out _))
|
||||
return;
|
||||
|
||||
prefix = input[..2];
|
||||
output = input[2..];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to resolve radio prefixes in chat messages (e.g., remove a leading ":e" and resolve the requested
|
||||
/// channel. Returns true if a radio message was attempted, even if the channel is invalid.
|
||||
|
||||
Reference in New Issue
Block a user