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 deltanedas
parent bb7f072dca
commit fb9e7f401c
1 changed files with 2 additions and 2 deletions

View File

@ -25,8 +25,7 @@ namespace Content.Shared.Preferences
[Serializable, NetSerializable]
public sealed partial class HumanoidCharacterProfile : ICharacterProfile
{
private static readonly Regex RestrictedNameRegex = new("[^\\u0030-\\u0039,\\u0041-\\u005A,\\u0061-\\u007A,\\u00C0-\\u00D6,\\u00D8-\\u00F6,\\u00F8-\\u00FF,\\u0100-\\u017F, '.,-]");
/*
/* DeltaV: Completely redid the regex:
* 0030-0039 Basic Latin: ASCII Digits
* 0041-005A Basic Latin: Uppercase Latin Alphabet
* 0061-007A Basic Latin: Lowercase Latin Alphabet
@ -35,6 +34,7 @@ namespace Content.Shared.Preferences
* 00F8-00FF Latin-1 Supplement: Letters III
* 0100-017F Latin Extended A: European Latin
*/
private static readonly Regex RestrictedNameRegex = new("[^\\u0030-\\u0039,\\u0041-\\u005A,\\u0061-\\u007A,\\u00C0-\\u00D6,\\u00D8-\\u00F6,\\u00F8-\\u00FF,\\u0100-\\u017F, '.,-]");
private static readonly Regex ICNameCaseRegex = new(@"^(?<word>\w)|\b(?<word>\w)(?=\w*$)");
public const int MaxNameLength = 32;