Repository navigation
Accept an arpa suffix in any case and without the root dot in fromArpa - #227
Merged
Merged
Conversation
Address4.fromArpa() stripped `.in-addr.arpa` only when a root dot followed it, so `1.0.0.127.in-addr.arpa` threw while `1.0.0.127.in-addr.arpa.` parsed; Address6.fromArpa() already accepted both. Neither family accepted an uppercase suffix, though DNS names are case-insensitive. Both now strip the suffix in any case, with or without the root dot. Address4.fromArpa() also gets its own tests, including the reverseForm round trip for a host and a network.
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.
Address4.fromArpa()stripped.in-addr.arpaonly when a root dot followed it, so1.0.0.127.in-addr.arpathrew with "IPv4 addresses are at most 15 characters." while1.0.0.127.in-addr.arpa.parsed.Address6.fromArpa()already accepted both. Neither family accepted an uppercase suffix, though DNS names are case-insensitive.The fix
Both suffix regexes are now
/(\.<suffix>)?\.?$/i. Everything else is unchanged: the reversed labels still go through the constructor, which rejects anything that is not four octets, andfromArpa(x.reverseForm())round-trips for a host and for a network.Tests
Address4.fromArpa()had no tests of its own. This adds a block covering the plain reversal, the suffix with and without the root dot, the suffix in mixed case, thereverseForm()round trip for/32,/24and/8, and rejection of names whose labels are not four octets.Address6.fromArpa()gets the mixed-case case alongside its existing prefix-length tests. The three new acceptance cases fail before the fix.Reported by @waydeshi via GHSA-329j-wj2f-jq5q, declined as an advisory and fixed as a correctness bug: the throw is a clean rejection of a valid form, and reversing
127.0.0.1.to1.0.0.127is the function doing what its name says, since127.0.0.1.in-addr.arpais the PTR name of1.0.0.127.