summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Halley <halley@dnspython.org>2013-04-26 13:04:01 +0100
committerBob Halley <halley@dnspython.org>2013-04-26 13:04:01 +0100
commita58c4192542197174e03fb297221e221681ee43e (patch)
tree3844be1453fb26401d07e1bc0f187f091d4ca04d
parent45ff3c53a2e70704b53521d04738e9408794da82 (diff)
downloaddnspython-a58c4192542197174e03fb297221e221681ee43e.tar.gz
In dns.ipv6.inet_ntoa(), do not use :: to shorten just one 16-bit 0 field
-rw-r--r--ChangeLog7
-rw-r--r--dns/ipv6.py2
-rw-r--r--tests/ntoaaton.py6
3 files changed, 14 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bae1b34..c8b5d92 100644
--- 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-08-28 Bob Halley <halley@dnspython.org>
* dns/rdtypes/ANY/NSEC3.py (NSEC3.from_text): The NSEC3 from_text()
diff --git a/dns/ipv6.py b/dns/ipv6.py
index 17d43a3..73f6232 100644
--- a/dns/ipv6.py
+++ b/dns/ipv6.py
@@ -67,7 +67,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'):
diff --git a/tests/ntoaaton.py b/tests/ntoaaton.py
index b103c21..bef83f3 100644
--- a/tests/ntoaaton.py
+++ b/tests/ntoaaton.py
@@ -193,5 +193,11 @@ class NtoAAtoNTestCase(unittest.TestCase):
for addr in addrs:
self.assertRaises(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.assertTrue(t1 == addr)
+
if __name__ == '__main__':
unittest.main()