]> git.ipfire.org Git - thirdparty/dnspython.git/commitdiff
In dns.ipv6.inet_ntoa(), do not use :: to shorten just one 16-bit 0 field
authorBob Halley <halley@dnspython.org>
Fri, 26 Apr 2013 12:03:42 +0000 (13:03 +0100)
committerBob Halley <halley@dnspython.org>
Fri, 26 Apr 2013 12:03:42 +0000 (13:03 +0100)
ChangeLog
dns/ipv6.py
tests/ntoaaton.py

index d3eda06a4069478167418de05bbd8ac2a94a285f..ef4ab5f4af143305b107d388dfee5d8b4b6fb93b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-04-26  Bob Halley  <halley@dnspython.org>
+
+       * dns/ipv6.py (inet_ntoa): We now comply with RFC 5952 section
+         5.2.2, by *not* using the :: syntax to shorten just one 16-bit
+         field.  Thanks to David Waitzman for reporting the bug and
+         suggesting the fix.
+
 2012-09-25  Sean Leach
 
        * added set_flags() method to dns.resolver.Resolver
index 69db34a7deac2268b354bfef69d27d945376f7d9..1ab00da9772b8d1ad075b1f31688b74e5b21c18a 100644 (file)
@@ -72,7 +72,7 @@ def inet_ntoa(address):
         if current_len > best_len:
             best_start = start
             best_len = current_len
-    if best_len > 0:
+    if best_len > 1:
         if best_start == 0 and \
            (best_len == 6 or
             best_len == 5 and chunks[5] == 'ffff'):
index 9d8bedd702d92679601ab7e597b858901bd17cb3..e93de2de21035c0ed97471cc61e31fe5ab85be4a 100644 (file)
@@ -193,5 +193,11 @@ class NtoAAtoNTestCase(unittest.TestCase):
         for addr in addrs:
             self.failUnlessRaises(dns.exception.SyntaxError, make_bad(addr))
 
+    def test_rfc5952_section_4_2_2(self):
+        addr = '2001:db8:0:1:1:1:1:1'
+        b1 = aton6(addr)
+        t1 = ntoa6(b1)
+        self.failUnless(t1 == addr)
+
 if __name__ == '__main__':
     unittest.main()