@@ -10,52 +10,52 @@ internal static partial class RegexPatterns
1010 private const RegexOptions Options = RegexOptions . IgnoreCase | RegexOptions . Compiled ;
1111 private static readonly TimeSpan DefaultTimeout = TimeSpan . FromSeconds ( 2 ) ; // unified timeout for non-GeneratedRegex fallbacks
1212
13- [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
13+ [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
1414 private const string SwitchArgumentRegexPattern = @"/\w+:" ;
1515
16- [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
16+ [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
1717 private const string ObscurePasswordRegexPattern = "(https?://)(.+)(:.+@)" ;
1818
19- [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
19+ [ StringSyntax ( StringSyntaxAttribute . Regex ) ]
2020 private const string ExpandTokensRegexPattern =
2121 """
22- \{ # Opening brace
23- (?: # Start of either env or member expression
24- env:(?!env:)(?<envvar>[A-Za-z_][A-Za-z0-9_]*) # Only a single env: prefix, not followed by another env:
25- | # OR
26- (?<member>[A-Za-z_][A-Za-z0-9_]*) # member/property name
27- (?: # Optional format specifier
28- :(?<format>[A-Za-z0-9\.\-,;'"]+) # Colon followed by format string (including semicolons and quotes for legacy composite format)
29- )? # Format is optional
30- ) # End group for env or member
31- (?: # Optional fallback group
32- \s*\?\?\s+ # '??' operator with optional whitespace: exactly two question marks for fallback
33- (?: # Fallback value alternatives:
34- (?<fallback>\w+) # A single word fallback
35- | # OR
36- "(?<fallback>[^"]*)" # A quoted string fallback
37- )
38- )? # Fallback is optional
39- \}
40- """ ;
41-
42- /// <summary>
43- /// Allow alphanumeric, underscore, colon (for custom format specification), hyphen, and dot
44- /// </summary>
45- [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
46- internal const string SanitizeEnvVarNameRegexPattern = @"^[A-Za-z0-9_:\-\.]+$" ;
47-
48- /// <summary>
49- /// Allow alphanumeric, underscore, and dot for property/field access
50- /// </summary>
51- [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
52- internal const string SanitizeMemberNameRegexPattern = @"^[A-Za-z0-9_\.]+$" ;
53-
54- [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
55- internal const string SanitizeNameRegexPattern = "[^a-zA-Z0-9-]" ;
56-
57- #if NET9_0_OR_GREATER
58- [ GeneratedRegex ( SwitchArgumentRegexPattern , Options ) ]
22+ \{ # Opening brace
23+ (?: # Start of either env or member expression
24+ env:(?!env:)(?<envvar>[A-Za-z_][A-Za-z0-9_]*) # Only a single env: prefix, not followed by another env:
25+ | # OR
26+ (?<member>[A-Za-z_][A-Za-z0-9_]*) # member/property name
27+ (?: # Optional format specifier
28+ :(?<format>[A-Za-z0-9\.\-,;'"]+) # Colon followed by format string (including semicolons and quotes for legacy composite format)
29+ )? # Format is optional
30+ ) # End group for env or member
31+ (?: # Optional fallback group
32+ \s*\?\?\s+ # '??' operator with optional whitespace: exactly two question marks for fallback
33+ (?: # Fallback value alternatives:
34+ (?<fallback>\w+) # A single word fallback
35+ | # OR
36+ "(?<fallback>[^"]*)" # A quoted string fallback
37+ )
38+ )? # Fallback is optional
39+ \}
40+ """ ;
41+
42+ /// <summary>
43+ /// Allow alphanumeric, underscore, colon (for custom format specification), hyphen, and dot
44+ /// </summary>
45+ [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
46+ internal const string SanitizeEnvVarNameRegexPattern = @"^[A-Za-z0-9_:\-\.]+$" ;
47+
48+ /// <summary>
49+ /// Allow alphanumeric, underscore, and dot for property/field access
50+ /// </summary>
51+ [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
52+ internal const string SanitizeMemberNameRegexPattern = @"^[A-Za-z0-9_\.]+$" ;
53+
54+ [ StringSyntax ( StringSyntaxAttribute . Regex , Options ) ]
55+ internal const string SanitizeNameRegexPattern = "[^a-zA-Z0-9-]" ;
56+
57+ #if NET9_0_OR_GREATER
58+ [ GeneratedRegex ( SwitchArgumentRegexPattern , Options ) ]
5959 public static partial Regex SwitchArgumentRegex { get ; }
6060#else
6161 [ GeneratedRegex ( SwitchArgumentRegexPattern , Options ) ]
@@ -65,7 +65,7 @@ internal static partial class RegexPatterns
6565#endif
6666
6767#if NET9_0_OR_GREATER
68- [ GeneratedRegex ( ObscurePasswordRegexPattern , Options ) ]
68+ [ GeneratedRegex ( ObscurePasswordRegexPattern , Options ) ]
6969 public static partial Regex ObscurePasswordRegex { get ; }
7070#else
7171 [ GeneratedRegex ( ObscurePasswordRegexPattern , Options ) ]
@@ -75,7 +75,7 @@ internal static partial class RegexPatterns
7575#endif
7676
7777#if NET9_0_OR_GREATER
78- [ GeneratedRegex ( ExpandTokensRegexPattern , RegexOptions . IgnorePatternWhitespace | Options ) ]
78+ [ GeneratedRegex ( ExpandTokensRegexPattern , RegexOptions . IgnorePatternWhitespace | Options ) ]
7979 public static partial Regex ExpandTokensRegex { get ; }
8080#else
8181 [ GeneratedRegex ( ExpandTokensRegexPattern , RegexOptions . IgnorePatternWhitespace | Options ) ]
@@ -85,7 +85,7 @@ internal static partial class RegexPatterns
8585#endif
8686
8787#if NET9_0_OR_GREATER
88- [ GeneratedRegex ( SanitizeEnvVarNameRegexPattern , Options ) ]
88+ [ GeneratedRegex ( SanitizeEnvVarNameRegexPattern , Options ) ]
8989 public static partial Regex SanitizeEnvVarNameRegex { get ; }
9090#else
9191 [ GeneratedRegex ( SanitizeEnvVarNameRegexPattern , Options ) ]
@@ -95,7 +95,7 @@ internal static partial class RegexPatterns
9595#endif
9696
9797#if NET9_0_OR_GREATER
98- [ GeneratedRegex ( SanitizeMemberNameRegexPattern , Options ) ]
98+ [ GeneratedRegex ( SanitizeMemberNameRegexPattern , Options ) ]
9999 public static partial Regex SanitizeMemberNameRegex { get ; }
100100#else
101101 [ GeneratedRegex ( SanitizeMemberNameRegexPattern , Options ) ]
@@ -105,7 +105,7 @@ internal static partial class RegexPatterns
105105#endif
106106
107107#if NET9_0_OR_GREATER
108- [ GeneratedRegex ( SanitizeNameRegexPattern , Options ) ]
108+ [ GeneratedRegex ( SanitizeNameRegexPattern , Options ) ]
109109 public static partial Regex SanitizeNameRegex { get ; }
110110#else
111111 [ GeneratedRegex ( SanitizeNameRegexPattern , Options ) ]
@@ -126,7 +126,7 @@ public static Regex GetOrAdd([StringSyntax(StringSyntaxAttribute.Regex)] string
126126 KnownRegexes . TryGetValue ( key , out var regex )
127127 ? regex
128128 : new Regex ( key , Options , DefaultTimeout ) ) ; // now uses timeout for safety
129- }
129+ }
130130
131131 // Descriptor used to centralize pattern + compiled regex instance. Extendable with options/timeout metadata later.
132132 private readonly record struct RegexDescriptor ( string Pattern , Regex Regex ) ;
0 commit comments