Repository navigation
Conversation
IPV6_REGEX and IP_REGEX only accepted an IPv4 tail after '::' with no groups between them (or after '::ffff:0:'), so valid addresses such as 0:0:0:0:0:ffff:192.168.1.1, ::1:2:3:4:192.168.1.1 and 64:ff9b:1::10.0.0.1 were rejected. Allow up to six groups before the IPv4 tail without compression and up to five with '::'.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 6 remain after this review. WalkthroughThe IPv6 regex and the IPv6 branch of the IP regex now cover additional IPv6 addresses with embedded IPv4 notation. Tests for Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The changes broaden IPv6 and IP validation for embedded IPv4 forms. No actionable merge-blocking risk is established in the supplied context. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
Summary
v.ipv6()andv.ip()reject valid IPv6 addresses whose last 32 bits are written as an IPv4 address, unless the IPv4 part comes straight after::(or after::ffff:0:), or afterx:...::with nothing between::and the IPv4 part.0:0:0:0:0:0:13.1.68.3and0:0:0:0:0:FFFF:129.144.52.38are the examples RFC 4291 section 2.2 (form 3) uses for this notation. Node'snet.isIPv6accepts all of the addresses above, and so does theformat: "ipv6"that@valibot/to-json-schemaemits for this action when it is checked with Ajv andajv-formats. Today a form that accepts addresses from a JSON Schema validator or from Node will reject some of the same addresses when it uses Valibot.Cause
The last two alternatives of
IPV6_REGEX(and the copy insideIP_REGEX) handle the IPv4 tail:::(?:ffff(?::0{1,4})?:)?<ipv4>(?:h16:){1,4}:<ipv4>Neither allows groups between
::and the IPv4 part (other thanffff:0), and there is no alternative for the uncompressed form with six groups.Changes
library/src/regex.ts: replace those two alternatives with the full set from the RFC 4291 / RFC 3986 grammar: six groups before the IPv4 part without::, orngroups (0 to 5), then::, then at most5 - ngroups before the IPv4 part. The new alternatives accept everything the old two did. The IPv4 octet pattern, theiflag and the other alternatives are unchanged, andIP_REGEXgets the same change.library/src/actions/ipv6/ipv6.test.tsandlibrary/src/actions/ip/ip.test.ts: new valid cases for the embedded IPv4 forms, and new invalid cases for embedded IPv4 addresses with too many groups (for example1:2:3:4:5:6:7:192.168.1.1and1:2:3:4:5:6::192.168.1.1). The valid cases fail on the currentmain.library/CHANGELOG.md: entry under the unreleased section.Out of scope: zone IDs on uncompressed link-local addresses (
fe80:0:0:0:1:2:3:4%eth0) and leading zeros in the embedded IPv4 octets. Both behave the same as before.Verification
In
library/:mainwithout the regex change: 2 failed (the new "embedded IPv4" tests inip.test.tsandipv6.test.ts).ip,ipv4andipv6tests pass (27 tests), and the full Vitest suite passes (280 files, 3234 tests).tsc --noEmit, and Prettier all pass. I did not rundeno checkbecause Deno isn't installed here.::and with and without an IPv4 tail, through both the new regex and Node'snet.isIPv6. They agreed on every string except the two out-of-scope cases above. Long crafted inputs (10k+ characters) match in under a millisecond.This PR was written with help from an AI coding assistant. I checked the diff, the tests and the results above.
Summary by CodeRabbit
ipandipv6now accept IPv6 addresses with embedded IPv4 addresses in the forms allowed by RFC 4291, while continuing to reject invalid or incomplete addresses.