ruby-on-railsrubyruby-3ruby-2.7ruby-3.1

Ruby IPAddr class accepting wrong IPv6 address string


We are middle of upgrading ruby versions v2.7.3 -> v3.1.3

One of our test cases are failing related to valid ipv6 address string, check the following

# ruby 2.7.3
IPAddr.new('fe80::85e:7530:69ec:9074%en0').ipv6?
=> IPAddr::InvalidAddressError (invalid address: fe80::85e:7530:69ec:9074%en0)

# ruby 3.1.3

IPAddr.new('fe80::85e:7530:69ec:9074%en0').ipv6?
=> true

Is it really a bug or am I missing something? Please help..


Solution

  • Is it really a bug or am I missing something?

    This used to be an issue in the ipaddr default gem up to version 1.2.2 which was fixed in version 1.2.3 in order to be fully compliant with RFC 4007 and RFC 6874. Version 1.2.3 of the ipaddr default gem was shipped as part of Ruby 3.1.0.

    So, you are correct. This is a bug (although opinions differ on that) which was fixed in ipaddr 1.2.3 / Ruby 3.1.0.