File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ def test_returns_true_on_valid_ipv4_address(address):
1919 ('1278.0.0.1' ,),
2020 ('127.0.0.abc' ,),
2121 ('900.200.100.75' ,),
22+ ('0127.0.0.1' ,),
2223])
2324def test_returns_failed_validation_on_invalid_ipv4_address (address ):
2425 assert isinstance (ipv4 (address ), ValidationFailure )
Original file line number Diff line number Diff line change @@ -23,8 +23,12 @@ def ipv4(value):
2323
2424 :param value: IP address string to validate
2525 """
26- groups = value .split ('.' )
27- if len (groups ) != 4 or any (not x .isdigit () for x in groups ):
26+ groups = value .split ("." )
27+ if (
28+ len (groups ) != 4
29+ or any (not x .isdigit () for x in groups )
30+ or any (len (x ) > 3 for x in groups )
31+ ):
2832 return False
2933 return all (0 <= int (part ) < 256 for part in groups )
3034
You can’t perform that action at this time.
0 commit comments