Project

General

Profile

Bug #14612 ยป resolv-ipv6-lowercase.patch

jeremyevans0 (Jeremy Evans), 06/20/2019 05:55 PM

View differences:

lib/resolv.rb
2530 2530
    attr_reader :address
2531 2531

  
2532 2532
    def to_s # :nodoc:
2533
      address = sprintf("%X:%X:%X:%X:%X:%X:%X:%X", *@address.unpack("nnnnnnnn"))
2533
      address = sprintf("%x:%x:%x:%x:%x:%x:%x:%x", *@address.unpack("nnnnnnnn"))
2534 2534
      unless address.sub!(/(^|:)0(:0)+(:|$)/, '::')
2535 2535
        address.sub!(/(^|:)0(:|$)/, '::')
2536 2536
      end
test/resolv/test_dns.rb
216 216
    assert_instance_of Resolv::IPv6, Resolv::IPv6.create('::1:127.0.0.1'), ref
217 217
  end
218 218

  
219
  def test_ipv6_to_s
220
    test_cases = [
221
      ["2001::abcd:abcd:abcd", "2001::ABcd:abcd:ABCD"],
222
      ["2001:db8::1", "2001:db8::0:1"],
223
      ["::", "0:0:0:0:0:0:0:0"],
224
      ["2001::", "2001::0"],
225
      ["2001:db8::1:1:1:1:1", "2001:db8:0:1:1:1:1:1"],
226
      ["1::1:0:0:0:1", "1:0:0:1:0:0:0:1"],
227
      ["1::1:0:0:1", "1:0:0:0:1:0:0:1"],
228
    ]
229

  
230
    test_cases.each do |expected, ipv6|
231
      assert_equal expected, Resolv::IPv6.create(ipv6).to_s
232
    end
233
  end
234

  
219 235
  def test_ipv6_should_be_16
220 236
    ref = '[rubygems:1626]'
221 237

  
222
-