Repository navigation
Reject zone IDs and brackets in netmask strings - #150
Open
mokshupadhyay wants to merge 1 commit into
Open
mokshupadhyay wants to merge 1 commit into
mokshupadhyay wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
IPAddr#mask!already rejects a netmask string that contains a/(IPAddr::InvalidAddressError, "invalid mask"), but a mask string with a zone ID (%eth0) or with brackets ([...]) was accepted: the string is handed toIPAddr.new, which accepts a zone ID or brackets in an address, and the result looked like a normal network.On
master:A netmask is not an address with a scope or a bracketed URL host, so these are not valid masks. With this change they raise
IPAddr::InvalidAddressError("invalid mask ..."), as a mask containing/already does. The pattern that detects an invalid mask inmask!goes from%r{/}to%r{[/%\[\]]}; masks without those characters are not affected.Tests:
test_s_new(TC_IPAddr) andtest_mask(TC_Operator) intest/test_ipaddr.rbget the four cases above. They fail onmaster("InvalidAddressError expected but nothing was raised") and pass now.bundle exec rake testpasses (44 tests, 655 assertions, 0 failures). Ruby 3.4.5.This does not overlap with #148, which changes how
mask!treats non-String, non-Integer arguments; this change only touches the pattern for String masks.