Skip to content

Commit c9627a1

Browse files
authored
Fix inadvertently case sensitive Boyer-Moore (#39420)
* Unit test * Fix * Typo * CR feedback
1 parent 423e164 commit c9627a1

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexCompiler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,9 +1335,8 @@ protected void GenerateFindFirstChar()
13351335
}
13361336

13371337
// ch = runtext[runtextpos];
1338-
// if (ch == lastChar) goto partialMatch;
13391338
Rightchar();
1340-
if (_boyerMoorePrefix.CaseInsensitive && ParticipatesInCaseConversion(chLast))
1339+
if (_boyerMoorePrefix.CaseInsensitive)
13411340
{
13421341
CallToLower();
13431342
}
@@ -1349,6 +1348,7 @@ protected void GenerateFindFirstChar()
13491348
Ldloc(chLocal);
13501349
Ldc(chLast);
13511350

1351+
// if (ch == lastChar) goto partialMatch;
13521352
BeqFar(lPartialMatch);
13531353

13541354
// ch -= lowAscii;

src/libraries/System.Text.RegularExpressions/tests/Regex.Match.Tests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ public class RegexMatchTests
1515
public static IEnumerable<object[]> Match_Basic_TestData()
1616
{
1717
// pattern, input, options, beginning, length, expectedSuccess, expectedValue
18+
yield return new object[] { @"H#", "#H#", RegexOptions.IgnoreCase, 0, 3, true, "H#" }; // https://github.com/dotnet/runtime/issues/39390
19+
yield return new object[] { @"H#", "#H#", RegexOptions.None, 0, 3, true, "H#" };
1820

1921
// Testing octal sequence matches: "\\060(\\061)?\\061"
2022
// Octal \061 is ASCII 49 ('1')

0 commit comments

Comments
 (0)