fix: reject \NN backrefs with non-octal leading digit#40
Draft
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Draft
fix: reject \NN backrefs with non-octal leading digit#40toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
toddr-bot wants to merge 1 commit intocpan-authors:mainfrom
Conversation
Multi-digit backreferences like \99, \80, \89 where the leading digit is 8 or 9 have no valid octal fallback (octal digits are 0-7). Previously the parser silently produced a null character (\000) followed by literal digits. Perl correctly rejects these as "Reference to nonexistent group". The fix checks the leading digit before attempting octal fallback in the backslash-digit handler. If the digit > 7, error immediately since no valid interpretation exists. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Reject multi-digit backreferences like
\99,\80,\89when no matching capture group exists and octal fallback is impossible.Why
Perl rejects these patterns as "Reference to nonexistent group" because digits 8 and 9 aren't valid octal. The parser was silently producing
\000(null) followed by literal digits — wrong output instead of an error.How
One-line guard in the backslash-digit handler: check if the leading digit > 7 before attempting octal fallback. If so, error immediately (RPe_BGROUP). Valid octal patterns like
\77and\100are unaffected.Testing
t/11errors.t(4 error cases + 2 octal fallback validations)\77,\80,\89,\98,\99,\100🤖 Generated with Claude Code
Quality Report
Changes: 2 files changed, 13 insertions(+)
Code scan: clean
Tests: passed (OK)
Branch hygiene: clean
Generated by Kōan post-mission quality pipeline