Fix nonsensical RegEx for name restriction (#34375)

* Fixed nonsense RegEx

"-" character is a range, caused an error.
No need for "," to repeat so much, it's not a separator.
"\\" - just why?

* Further optimized RegEx structure

Added:
"@" delimiter for consistency
"/" to escape "-" for good and to avoid further problems
This commit is contained in:
Hyper B
2025-01-15 20:59:04 +05:00
committed by GitHub
parent d83b5acb22
commit e752561d20

View File

@@ -25,7 +25,7 @@ namespace Content.Shared.Preferences
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterProfile : ICharacterProfile
{
private static readonly Regex RestrictedNameRegex = new("[^A-Z,a-z,0-9, ,\\-,']");
private static readonly Regex RestrictedNameRegex = new(@"[^A-Za-z0-9 '\-]");
private static readonly Regex ICNameCaseRegex = new(@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)");
public const int MaxNameLength = 32;