From fb9e7f401c26044d038bd23566456a4025619260 Mon Sep 17 00:00:00 2001 From: Hyper B <137433177+HyperB1@users.noreply.github.com> Date: Wed, 15 Jan 2025 20:59:04 +0500 Subject: [PATCH] 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 --- Content.Shared/Preferences/HumanoidCharacterProfile.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Preferences/HumanoidCharacterProfile.cs b/Content.Shared/Preferences/HumanoidCharacterProfile.cs index 4c8eb40c9d..5b574d2bd9 100644 --- a/Content.Shared/Preferences/HumanoidCharacterProfile.cs +++ b/Content.Shared/Preferences/HumanoidCharacterProfile.cs @@ -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(@"^(?\w)|\b(?\w)(?=\w*$)"); public const int MaxNameLength = 32;