From 7e8ea49bfb6b1c9620d6059f181915ebb3d18cbb Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Mon, 6 Jul 2026 17:00:21 -0700 Subject: [PATCH 1/2] Clarify regex warnings --- .../src/System/Text/RegularExpressions/Regex.cs | 14 ++++++-------- .../System/Text/RegularExpressions/RegexOptions.cs | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs index 6ffb0d3fb3683e..60790fb89acbd6 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Regex.cs @@ -19,14 +19,12 @@ namespace System.Text.RegularExpressions /// Represents an immutable regular expression. Also contains static methods that /// allow use of regular expressions without instantiating a Regex explicitly. /// - /// - /// - /// The class represents the .NET regular expression engine. - /// It can be used to quickly parse large amounts of text to find specific character patterns; - /// to extract, edit, replace, or delete text substrings; and to add the extracted strings to a - /// collection to generate a report. - /// - /// + /// class represents the .NET regular expression engine. It can be used to quickly parse large amounts of text to find specific character patterns; to extract, edit, replace, or delete text substrings; and to add the extracted strings to a collection to generate a report. + /// + /// > [!WARNING] + /// > Unrestricted use of this class with untrusted input can subject applications to [denial-of-service attacks](https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS). Consult [Best practices for regular expressions in .NET](https://learn.microsoft.com/dotnet/standard/base-types/best-practices-regex) for guidance on how to safely use this class with untrusted input. + /// ]]> /// .NET Regular Expression Language /// Regular Expression Options /// Best Practices for Regular Expressions diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs index 73fed871e37ff6..a6a6a198a5db3f 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs @@ -122,7 +122,7 @@ enum RegexOptions /// /// Enable matching using an approach that avoids backtracking and guarantees linear-time processing - /// in the length of the input. For more information, see the + /// in the length of the input. For more information, see the "Non-Backtracking mode" section in the /// /// Regular Expression Options article. /// From 3a2d5a8a68111698f367d763e1d20b942b9069b3 Mon Sep 17 00:00:00 2001 From: Levi Broderick Date: Mon, 6 Jul 2026 17:08:04 -0700 Subject: [PATCH 2/2] Fixed typo --- .../src/System/Text/RegularExpressions/RegexOptions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs index a6a6a198a5db3f..3f90cd190aadc3 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexOptions.cs @@ -122,7 +122,7 @@ enum RegexOptions /// /// Enable matching using an approach that avoids backtracking and guarantees linear-time processing - /// in the length of the input. For more information, see the "Non-Backtracking mode" section in the + /// in the length of the input. For more information, see the "NonBacktracking mode" section in the /// /// Regular Expression Options article. ///