@@ -63,8 +63,6 @@ namespace Hangfire.States
63
63
/// <threadsafety static="true" instance="false" />
64
64
public class EnqueuedState : IState
65
65
{
66
- private static readonly Regex ValidationRegex = new Regex ( @"^[a-z0-9_-]+$" , RegexOptions . Compiled | RegexOptions . CultureInvariant , TimeSpan . FromSeconds ( 5 ) ) ;
67
-
68
66
/// <summary>
69
67
/// Represents the default queue name. This field is constant.
70
68
/// </summary>
@@ -232,7 +230,7 @@ internal static bool TryValidateQueueName([NotNull] string value)
232
230
throw new ArgumentNullException ( nameof ( value ) ) ;
233
231
}
234
232
235
- return ValidationRegex . IsMatch ( value ) ;
233
+ return ValidateQueueNameInner ( value ) ;
236
234
}
237
235
238
236
internal static void ValidateQueueName ( [ InvokerParameterName ] string parameterName , [ NotNull ] string value )
@@ -242,14 +240,28 @@ internal static void ValidateQueueName([InvokerParameterName] string parameterNa
242
240
throw new ArgumentNullException ( parameterName ) ;
243
241
}
244
242
245
- if ( ! ValidationRegex . IsMatch ( value ) )
243
+ if ( ! ValidateQueueNameInner ( value ) )
246
244
{
247
245
throw new ArgumentException (
248
246
$ "The queue name must consist of lowercase letters, digits, underscore, and dash characters only. Given: '{ value } '.",
249
247
parameterName ) ;
250
248
}
251
249
}
252
250
251
+ private static bool ValidateQueueNameInner ( string value )
252
+ {
253
+ foreach ( var ch in value )
254
+ {
255
+ // ^[a-z0-9_-]+$
256
+ if ( ! ( ( ch >= 'a' && ch <= 'z' ) || ( ch >= '0' && ch <= '9' ) || ch == '-' || ch == '_' ) )
257
+ {
258
+ return false ;
259
+ }
260
+ }
261
+
262
+ return true ;
263
+ }
264
+
253
265
internal sealed class Handler : IStateHandler
254
266
{
255
267
public void Apply ( ApplyStateContext context , IWriteOnlyTransaction transaction )
0 commit comments