Skip to content

Accept all RFC 6874 unreserved characters in IPv6 zone IDs - #217

Merged
whitequark merged 1 commit into
whitequark:mainfrom
wleeaf:allow-rfc6874-zone-ids
Oct 25, 2026
Merged

whitequark merged 1 commit into
whitequark:mainfrom
wleeaf:allow-rfc6874-zone-ids

Conversation

@wleeaf

@wleeaf wleeaf commented Oct 25, 2026

Copy link
Copy Markdown
Contributor

The zone ID pattern only allows letters and digits, so link-local addresses on common interfaces are rejected:

ipaddr.IPv6.isValid('fe80::1%eth0');      // true
ipaddr.IPv6.isValid('fe80::1%eth0.100');  // false (VLAN interface)
ipaddr.IPv6.parse('fe80::1%br-lan');      // throws: string is not formatted like an IPv6 Address (bridge, e.g. OpenWrt)
ipaddr.IPv6.parse('fe80::1%en_0');        // throws

RFC 6874 (section 2) defines ZoneID = 1*( unreserved / pct-encoded ), and unreserved is ALPHA / DIGIT / "-" / "." / "_" / "~". Python's ipaddress accepts them too (ipaddress.IPv6Address('fe80::1%br-lan')).

The zoneIndex pattern is now %[0-9a-z._~-]{1,}. It is shared by the native and transitional IPv6 patterns and by the zone extraction in expandIPv6, so parse, isValid, parseCIDR and IPv4-mapped addresses with a zone all accept the new characters. A zone ID still can't be empty or contain spaces, % or /.

The new test accepts zone IDs with the other RFC 6874 unreserved characters covers ., -, _ and ~, an IPv4-mapped address, parseCIDR, and two invalid zone IDs. It fails without the change. npm test (71 tests) and npm run lint pass.

The zone ID pattern only allowed letters and digits, so addresses with
common interface names were rejected: fe80::1%eth0.100 (a VLAN
interface), fe80::1%br-lan (a bridge) or fe80::1%en_0. RFC 6874 defines
ZoneID = 1*( unreserved / pct-encoded ), and unreserved also includes
"-", ".", "_" and "~". The pattern now accepts those as well.
Copilot AI balanced review requested due to automatic review settings October 25, 2026 04:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@whitequark
whitequark merged commit 3e7c4e7 into whitequark:main Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants