implement wildcard lenght quantifiers, TreatAsRegex property and solve catastrpohic backtracking (#2528)

This commit is contained in:
Cenk Ergen
2022-12-14 17:06:57 +03:00
committed by GitHub
parent 25cfb8822f
commit 3b107c2d01
9 changed files with 89 additions and 7 deletions

View File

@@ -35,6 +35,9 @@ namespace Discord.Interactions.Builders
/// <inheritdoc/>
public bool IgnoreGroupNames { get; set; }
/// <inheritdoc/>
public bool TreatNameAsRegex { get; set; }
/// <inheritdoc/>
public RunMode RunMode { get; set; }
@@ -117,6 +120,19 @@ namespace Discord.Interactions.Builders
return Instance;
}
/// <summary>
/// Sets <see cref="TreatNameAsRegex"/>.
/// </summary>
/// <param name="value">New value of the <see cref="TreatNameAsRegex"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>
public TBuilder WithNameAsRegex (bool value)
{
TreatNameAsRegex = value;
return Instance;
}
/// <summary>
/// Adds parameter builders to <see cref="Parameters"/>.
/// </summary>
@@ -163,6 +179,10 @@ namespace Discord.Interactions.Builders
ICommandBuilder ICommandBuilder.SetRunMode (RunMode runMode) =>
SetRunMode(runMode);
/// <inheritdoc/>
ICommandBuilder ICommandBuilder.WithNameAsRegex(bool value) =>
WithNameAsRegex(value);
/// <inheritdoc/>
ICommandBuilder ICommandBuilder.AddParameters (params IParameterBuilder[] parameters) =>
AddParameters(parameters as TParamBuilder);

View File

@@ -34,6 +34,11 @@ namespace Discord.Interactions.Builders
/// </summary>
bool IgnoreGroupNames { get; set; }
/// <summary>
/// Gets or sets whether the <see cref="Name"/> should be directly used as a Regex pattern.
/// </summary>
bool TreatNameAsRegex { get; set; }
/// <summary>
/// Gets or sets the run mode this command gets executed with.
/// </summary>
@@ -90,6 +95,15 @@ namespace Discord.Interactions.Builders
/// </returns>
ICommandBuilder SetRunMode (RunMode runMode);
/// <summary>
/// Sets <see cref="TreatNameAsRegex"/>.
/// </summary>
/// <param name="value">New value of the <see cref="TreatNameAsRegex"/>.</param>
/// <returns>
/// The builder instance.
/// </returns>
ICommandBuilder WithNameAsRegex(bool value);
/// <summary>
/// Adds parameter builders to <see cref="Parameters"/>.
/// </summary>