-
-
Save simonmcc/6089490 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/designate/schema.py b/designate/schema.py | |
| index f813a30..c1c1907 100644 | |
| --- a/designate/schema.py | |
| +++ b/designate/schema.py | |
| @@ -109,6 +109,14 @@ class SchemaValidator(jsonschema.Draft3Validator): | |
| if instance == '0.0.0.0': # RFC5735 | |
| msg = "%s is not an IPv4 address" % (instance) | |
| yield jsonschema.ValidationError(msg) | |
| + # is it a dotted quad & all 4 fields <= 255 | |
| + m = re.match('(\d+)\.(\d+)\.(\d+)\.(\d+)$', instance) | |
| + if not (m and (int(m.group(1)) <= 255 and | |
| + int(m.group(2)) <= 255 and | |
| + int(m.group(3)) <= 255 and | |
| + int(m.group(4)) <= 255)): | |
| + msg = "%s is not an IPv4 address" % (instance) | |
| + yield jsonschema.ValidationError(msg) | |
| elif format == "ipv6": | |
| # IPv6 Address | |
| if self.is_type(instance, "string"): | |
| diff --git a/designate/tests/test_schema.py b/designate/tests/test_schema.py | |
| index 62e97c1..b954e8b 100644 | |
| --- a/designate/tests/test_schema.py | |
| +++ b/designate/tests/test_schema.py | |
| @@ -49,6 +49,9 @@ class TestSchemaValidator(TestCase): | |
| '0.0.256.0', | |
| '0.256.0.0', | |
| '256.0.0.0', | |
| + '127.0.0', | |
| + '127.0.0.999', | |
| + '127.0..1', | |
| ] | |
| for ipaddress in valid_ipaddresses: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment