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

<regex>: Limit backreference parsing to single digit for basic regular expressions #5167

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

muellerj2
Copy link
Contributor

@muellerj2 muellerj2 commented Dec 6, 2024

According to Sections 9.3.6 and 9.5.1 of the POSIX standard, a backreference is a backslash followed by a single digit, so \1 to \9. Thus, \(a\)\10 is a valid basic regular expression matching the string aa0, because \10 is a backreference to capture group 1 (\(a\)) plus the digit 0. However, the regex parser currently rejects this regular expression because it interprets \10 as a backreference to capture group 10.

After this PR, the parser only reads a single digit in basic regular expression (and grep) mode, so \10 is parsed correctly as a backreference to capture group 1 plus digit 0.

@muellerj2 muellerj2 requested a review from a team as a code owner December 6, 2024 15:03
@CaseyCarter CaseyCarter added the bug Something isn't working label Dec 7, 2024
@StephanTLavavej StephanTLavavej self-assigned this Dec 7, 2024
stl/inc/regex Outdated Show resolved Hide resolved
@StephanTLavavej StephanTLavavej removed their assignment Dec 9, 2024
@StephanTLavavej StephanTLavavej self-assigned this Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Initial Review
Development

Successfully merging this pull request may close these issues.

3 participants