Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/7.0] Fix RegexOptions.NonBacktracking matching end anchors at timeout check boundaries #75308

Merged
merged 6 commits into from
Sep 9, 2022

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Sep 8, 2022

Backport of #74525 to release/7.0

/cc @stephentoub @olsaarik

Customer Impact

This is fixing a correctness bug on our (new in .NET 7) NonBacktracking Regex engine. This is an edge case, which is why it wasn't caught during the development of the engine. Without this fix the code will incorrectly return that Regex.IsMatch(string.Concat(new string('a', 999), "bc"), "^a*b$", RegexOptions.NonBacktracking) is true. Issue is with the logic we have when we exit from loops for doing timeout checks, which is how @olsaarik found the issue.

Testing

This was just an edge case missed originally. We have now added a test case to make sure it is not regressed.

Risk

Low. This is a brand new engine, and the changes on this PR are strictly about correctness.

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

@ghost
Copy link

ghost commented Sep 8, 2022

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Issue Details

Backport of #74525 to release/7.0

/cc @stephentoub @olsaarik

Customer Impact

Testing

Risk

IMPORTANT: Is this backport for a servicing release? If so and this change touches code that ships in a NuGet package, please make certain that you have added any necessary package authoring and gotten it explicitly reviewed.

Author: github-actions[bot]
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: -

@carlossanlop
Copy link
Member

@danmoseley can we get your seal of approval, please?

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I filled the template above to make it easier. This is a correctness fix, so it would be good to get into 7.0.

@danmoseley
Copy link
Member

Approved. Correctness of regex is important. New code/new scenario, risk localized to new engine.

@carlossanlop
Copy link
Member

Approved and signed off.
CI failure unrelated.
Ready to merge. :shipit:

@carlossanlop carlossanlop merged commit d18ff87 into release/7.0 Sep 9, 2022
@carlossanlop carlossanlop deleted the backport/pr-74525-to-release/7.0 branch September 9, 2022 04:34
@ghost ghost locked as resolved and limited conversation to collaborators Oct 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants