diff --git a/django/core/validators.py b/django/core/validators.py index 5a7fd1a49b..067a3743eb 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -252,7 +252,7 @@ validate_unicode_slug = RegexValidator( 'invalid' ) -ipv4_re = _lazy_re_compile(r'^(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\Z') +ipv4_re = _lazy_re_compile(r'^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9])){3}\Z') validate_ipv4_address = RegexValidator(ipv4_re, _('Enter a valid IPv4 address.'), 'invalid') diff --git a/tests/validators/tests.py b/tests/validators/tests.py index 459324fb74..88273eaae1 100644 --- a/tests/validators/tests.py +++ b/tests/validators/tests.py @@ -138,6 +138,7 @@ TEST_DATA = [ (validate_ipv4_address, '25,1,1,1', ValidationError), (validate_ipv4_address, '25.1 .1.1', ValidationError), (validate_ipv4_address, '1.1.1.1\n', ValidationError), + (validate_ipv4_address, '٧.2٥.3٣.243', ValidationError), # validate_ipv6_address uses django.utils.ipv6, which # is tested in much greater detail in its own testcase