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:
@@ -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
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user