Skip to content

Allow full CIDR range (1-128) for IPv6 literals in HRW4U grammar#13077

Open
Clendenin wants to merge 1 commit intoapache:masterfrom
Clendenin:hrw4u-ipv6-cidr-fix
Open

Allow full CIDR range (1-128) for IPv6 literals in HRW4U grammar#13077
Clendenin wants to merge 1 commit intoapache:masterfrom
Clendenin:hrw4u-ipv6-cidr-fix

Conversation

@Clendenin
Copy link
Copy Markdown

Summary

The IPV6_CIDR lexer fragment in the HRW4U grammar rejected values
1-32, reserving them exclusively for IPV4_CIDR. This caused valid
IPv6 prefixes like 2620:149:a00::/32 to fail with a lexer error.

The restriction was unnecessary because IPV4_LITERAL and
IPV6_LITERAL are already unambiguous at the lexer level: IPv4
requires 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_CIDR from 33-128 to 1-128.

@ezelkow1
Copy link
Copy Markdown
Member

ezelkow1 commented Apr 9, 2026

[approve ci]

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_CIDR in hrw4u.g4 to accept the full intended IPv6 prefix range 1–128 (previously 33–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.

@zwoop zwoop added this to the 11.0.0 milestone Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants