decode scoped IPv6 addresses instead of rejecting them#324
Merged
agronholm merged 2 commits intoJul 4, 2026
Conversation
ff5cc58 to
11c1c2f
Compare
agronholm
approved these changes
Jul 4, 2026
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.
Changes
A scoped IPv6 address survives encoding but blows up on the way back in.
encode_ipv6_addressserialises anIPv6Addressthat carries ascope_idas the tag 54 array[address, null, zone id], butdecode_ipv6only recognised the[prefix, address]network form and the[address, prefix]interface form. The null second element falls straight through to the catch-all, soloads(dumps(IPv6Address("fe80::1%eth0")))raisesCBORDecodeError: invalid types in input arrayrather than returning the address. Anything holding a link-local address with a zone id therefore cannot be round-tripped, and the failure is silent until you actually feed such a value back through the decoder.I hoisted the zone id suffix formatting above the type match (it is common to every array form) and added a branch that reads a null second element with a bytes first element as a bare scoped address, constructing the
IPv6Addresswith the%zonesuffix directly instead of routing it through the network/interface class. The network and interface paths, including the over-length address check, are untouched.Checklist
tests/) which would fail without your patchdocs/), in case of behavior changes or new featuresdocs/versionhistory.rst).