Repository navigation
Warn on bracketed IPv6 address with a prefix length - #130
Merged
Merged
Conversation
IPAddr.new("[2001:db8::]/32") is currently accepted and treated the
same as IPAddr.new("2001:db8::/32"). However, square brackets are a
delimiter for embedding an address in a larger syntax such as
host:port (RFC 5952 section 6), and no notation is defined for a
prefix length after the closing bracket.
Print a warning for this form, saying that it will raise
IPAddr::InvalidAddressError in a future version. The result is
unchanged for now. "[2001:db8::]" and "2001:db8::/32" are not
affected.
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.
Summary
IPAddr.new("[2001:db8::]/32")is currently accepted and treated the same asIPAddr.new("2001:db8::/32").However, square brackets are a delimiter for embedding an address in a larger syntax such as host:port, and no notation is defined for a prefix length after the closing bracket.
This change prints a warning for this form, saying that it will raise
IPAddr::InvalidAddressErrorin a future version. The result is unchanged for now.Why
[2001:db8::]/32is invalidRFC 5952: Section 6 defines how an IPv6 address is combined with a port number in text. It says the
[]style from RFC 3986 should be used by default (e.g.[2001:db8::1]:80), and that URIs containing IPv6 literals must follow RFC 3986.In other words, square brackets wrap the address only, as a delimiter for embedding it in a larger syntax.
The RFC does not define a form in which a prefix length follows the closing bracket.
The valid forms are
[2001:db8::](bare address in bracketed style) and2001:db8::/32(address with a prefix length, no brackets).Changes
This Pull Request adds a warning that is printed when a bracketed IPv6 address is followed by a prefix length or a mask.
Behavior
"[2001:db8::]""2001:db8::/32""[2001:db8::]/32"Example: