Allow full CIDR range (1-128) for IPv6 literals in HRW4U grammar#13077
Open
Clendenin wants to merge 1 commit intoapache:masterfrom
Open
Allow full CIDR range (1-128) for IPv6 literals in HRW4U grammar#13077Clendenin wants to merge 1 commit intoapache:masterfrom
Clendenin wants to merge 1 commit intoapache:masterfrom
Conversation
Member
|
[approve ci] |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes an overly restrictive IPv6 CIDR lexer fragment in the HRW4U grammar so valid IPv6 prefixes like ...::/32 tokenize correctly.
Changes:
- Expand
IPV6_CIDRinhrw4u.g4to accept the full intended IPv6 prefix range1–128(previously33–128). - Add a new grammar/output golden test case covering IPv6 CIDR values that overlap with the IPv4 CIDR range (e.g.,
/31,/32).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
tools/hrw4u/grammar/hrw4u.g4 |
Broadens the IPv6 CIDR lexer fragment to allow /1 through /128, fixing lexer errors for valid IPv6 prefixes like /32. |
tools/hrw4u/tests/data/conds/ipv6-cidr.input.txt |
Adds a forward-compilation test input that includes IPv6 literals with /31 and /32. |
tools/hrw4u/tests/data/conds/ipv6-cidr.output.txt |
Adds the expected compiled header_rewrite output for the new IPv6 CIDR test input. |
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.
Summary
The
IPV6_CIDRlexer fragment in the HRW4U grammar rejected values1-32, reserving them exclusively for
IPV4_CIDR. This caused validIPv6 prefixes like
2620:149:a00::/32to fail with a lexer error.The restriction was unnecessary because
IPV4_LITERALandIPV6_LITERALare already unambiguous at the lexer level: IPv4requires dots, IPv6 requires colons. The CIDR fragments are consumed
inside these parent token rules, so they never compete. This was
verified by tokenizing overlapping CIDR values through the generated
ANTLR lexer.
The fix expands
IPV6_CIDRfrom 33-128 to 1-128.