Ensure all errors raised from netaddr are caught

Some values would cause schema validation to fail, even if those values
were valid for the record type being created.

Change-Id: I5d85a6edd6bffeb2acf3d48037f1507611b18170
This commit is contained in:
Kiall Mac Innes
2013-08-06 20:23:13 +01:00
parent d46293d295
commit fc90fda6d0
2 changed files with 5 additions and 2 deletions

View File

@@ -31,7 +31,7 @@ def is_ipv4(instance):
# netaddr happly accepts, and expands "127.0" into "127.0.0.0"
if str(address) != instance:
return False
except netaddr.AddrFormatError:
except Exception:
return False
if instance == '0.0.0.0': # RFC5735
@@ -44,7 +44,7 @@ def is_ipv4(instance):
def is_ipv6(instance):
try:
netaddr.IPAddress(instance, version=6)
except netaddr.AddrFormatError:
except Exception:
return False
return True

View File

@@ -42,6 +42,9 @@ class SchemaFormatTest(TestCase):
'-1.0.0.1',
'1.0.-0.1',
'1.0.0.-1',
'ABCDEF',
'ABC/DEF',
'ABC\\DEF',
]
for ipaddress in valid_ipaddresses: