diff options
| author | Bob Halley <halley@nominum.com> | 2011-07-12 19:00:28 -0700 |
|---|---|---|
| committer | Bob Halley <halley@nominum.com> | 2011-07-12 19:00:28 -0700 |
| commit | b8aef115ea80a6f0ec3cc6efec2011cadfad8e7f (patch) | |
| tree | 6013f4084ca15731bdf2e5a2cdec8ebefc484a20 /dns | |
| parent | 490083eebe545d753089f9ec90957d5ec68a4e45 (diff) | |
| download | dnspython-b8aef115ea80a6f0ec3cc6efec2011cadfad8e7f.tar.gz | |
more v6 strictness; more unit tests
Diffstat (limited to 'dns')
| -rw-r--r-- | dns/ipv6.py | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/dns/ipv6.py b/dns/ipv6.py index 4b9312b..e2bcecd 100644 --- a/dns/ipv6.py +++ b/dns/ipv6.py @@ -84,7 +84,7 @@ def inet_ntoa(address): hex = ':'.join(chunks) return hex -_v4_ending = re.compile(r'(.*):(\d+)\.(\d+)\.(\d+)\.(\d+)$') +_v4_ending = re.compile(r'(.*):(\d+\.\d+\.\d+\.\d+)$') _colon_colon_start = re.compile(r'::.*') _colon_colon_end = re.compile(r'.*::$') @@ -108,16 +108,8 @@ def inet_aton(text): # m = _v4_ending.match(text) if not m is None: - try: - b1 = int(m.group(2)) - b2 = int(m.group(3)) - b3 = int(m.group(4)) - b4 = int(m.group(5)) - except: - raise dns.exception.SyntaxError - if b1 > 255 or b2 > 255 or b3 > 255 or b4 > 255: - raise dns.exception.SyntaxError - text = "%s:%04x:%04x" % (m.group(1), b1 * 256 + b2, b3 * 256 + b4) + b = dns.ipv4.inet_aton(m.group(2)) + text = "%s:%02x%02x:%02x%02x" % (m.group(1), b[0], b[1], b[2], b[3]) # # Try to turn '::<whatever>' into ':<whatever>'; if no match try to # turn '<whatever>::' into '<whatever>:' @@ -161,5 +153,5 @@ def inet_aton(text): # try: return bytes.fromhex(text) - except TypeError: + except: raise dns.exception.SyntaxError |
