mirror of
https://github.com/MikuLeaks/MikuSB.git
synced 2026-06-04 13:43:58 +00:00
Fixed a critical issue with in-game chat.
This commit is contained in:
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
27
GameServer/Game/Player/ChatMessageHelper.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace MikuSB.GameServer.Game.Player;
|
||||
|
||||
public static partial class ChatMessageHelper
|
||||
{
|
||||
[GeneratedRegex(@"\s+")]
|
||||
private static partial Regex MultiWhitespaceRegex();
|
||||
|
||||
public static uint BuildClientTimestamp()
|
||||
{
|
||||
return (uint)MikuSB.Util.Extensions.Extensions.GetUnixSec();
|
||||
}
|
||||
|
||||
public static string NormalizeForClient(string? text)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(text))
|
||||
return string.Empty;
|
||||
|
||||
var normalized = text
|
||||
.Replace("\r\n", " ")
|
||||
.Replace('\r', ' ')
|
||||
.Replace('\n', ' ');
|
||||
|
||||
return MultiWhitespaceRegex().Replace(normalized, " ").Trim();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user