From 9d1eef4c7bed606b197af819ba8b0347d27e63af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:11:11 +0000 Subject: [PATCH 1/3] Initial plan From a233d040e1a461f48aff86dff8d125a8096660a8 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 16:47:44 +0000 Subject: [PATCH 2/3] Fix vertical tab handling in RegexOptions.IgnorePatternWhitespace Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- .../src/System/Text/RegularExpressions/RegexParser.cs | 4 ++-- .../tests/FunctionalTests/Regex.Match.Tests.cs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs index 7287e39125f1e1..edd7dfff101527 100644 --- a/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs +++ b/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexParser.cs @@ -1929,7 +1929,7 @@ internal static int MapCaptureNumber(int capnum, Hashtable? caps) => private static ReadOnlySpan Category => [ // 0 1 2 3 4 5 6 7 8 9 A B C D E F 0 1 2 3 4 5 6 7 8 9 A B C D E F - 0, 0, 0, 0, 0, 0, 0, 0, 0, W, W, 0, W, W, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, W, W, W, W, W, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? W, 0, 0, Z, S, 0, 0, 0, S, S, Q, Q, 0, 0, S, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, Q, // @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ @@ -1939,7 +1939,7 @@ internal static int MapCaptureNumber(int capnum, Hashtable? caps) => ]; private static readonly SearchValues s_metachars = - SearchValues.Create("\t\n\f\r #$()*+.?[\\^{|"); + SearchValues.Create("\t\n\v\f\r #$()*+.?[\\^{|"); /// Returns true for those characters that terminate a string of ordinary chars. private static bool IsSpecial(char ch) => ch <= '|' && Category[ch] >= S; diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index 01553e0659b850..6a1152db4358bd 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -581,6 +581,9 @@ public static IEnumerable Match_MemberData() // "x" option. Removes unescaped whitespace from the pattern. : Actual - "\x20([^/]+)\x20","x" yield return ("\x20([^/]+)\x20\x20\x20\x20\x20\x20\x20", " abc ", RegexOptions.IgnorePatternWhitespace, 0, 10, true, " abc "); + // "x" option. Vertical tab should be ignored as whitespace + yield return ("a\vb", "ab", RegexOptions.IgnorePatternWhitespace, 0, 2, true, "ab"); + // Turning on case insensitive option in mid-pattern : Actual - "aaa(?i:match this)bbb" if ("i".ToUpper() == "I") { From c5ec742367171e10478bb26fd88b993d469a227a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 11 Oct 2025 18:39:00 +0000 Subject: [PATCH 3/3] Guard vertical tab test for netfx platform Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- .../tests/FunctionalTests/Regex.Match.Tests.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs index 6a1152db4358bd..13a7d4daaea6dc 100644 --- a/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs +++ b/src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs @@ -582,7 +582,10 @@ public static IEnumerable Match_MemberData() yield return ("\x20([^/]+)\x20\x20\x20\x20\x20\x20\x20", " abc ", RegexOptions.IgnorePatternWhitespace, 0, 10, true, " abc "); // "x" option. Vertical tab should be ignored as whitespace - yield return ("a\vb", "ab", RegexOptions.IgnorePatternWhitespace, 0, 2, true, "ab"); + if (!PlatformDetection.IsNetFramework) + { + yield return ("a\vb", "ab", RegexOptions.IgnorePatternWhitespace, 0, 2, true, "ab"); + } // Turning on case insensitive option in mid-pattern : Actual - "aaa(?i:match this)bbb" if ("i".ToUpper() == "I")