Skip to content

Navigation Menu

Sign in
Sign up

fix(ipaddr): strict IPv6 validation — reject :: with zero compression and hextets >4 hex digits - #206

Merged
whitequark merged 3 commits into
whitequark:main from
luojiyin1987:fix/strict-ipv6-validation
Jun 27, 2026
Merged

fix(ipaddr): strict IPv6 validation — reject :: with zero compression and hextets >4 hex digits #206
whitequark merged 3 commits into
whitequark:main from
luojiyin1987:fix/strict-ipv6-validation

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Jun 27, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Closes #205

Changes

lib/ipaddr.js

  1. colonCount > partscolonCount >= parts — reject IPv6 addresses where :: compresses zero parts (e.g. 1:2:3:4:5:6:7:8::, ::1:2:3:4:5:6:7:8), per RFC 4291
  2. Hextet length check — reject hextets longer than 4 hexadecimal digits (e.g. 00000::1), per RFC 4291 section 2.2

test/ipaddr.test.js

  • Added test: "rejects IPv6 parts longer than four hexadecimal digits"
  • Added test coverage for IPv4-embedded IPv6 with overlong hextets
  • Added test: "rejects compression of zero IPv6 parts"
  • Added regression test to ensure compression of exactly one IPv6 part remains valid

@whitequark whitequark left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks!

whitequark merged commit a180e78 into whitequark:main Jun 27, 2026
4 checks passed
luojiyin1987 deleted the fix/strict-ipv6-validation branch June 27, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@whitequark whitequark whitequark approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

fix: strict IPv6 validation — reject :: with zero compression and hextets >4 hex digits

AltStyle によって変換されたページ (->オリジナル) /