diff options
| author | Florian Apolloner <florian@apolloner.eu> | 2013-02-23 18:42:53 +0100 |
|---|---|---|
| committer | Florian Apolloner <florian@apolloner.eu> | 2013-02-23 18:43:34 +0100 |
| commit | 5ae0c933a8572c173401386f9037901e6b5fff2b (patch) | |
| tree | e456f9b462017096250f027ac98dd047f8613722 /django | |
| parent | cc53d9b30bd73c12413c28101d5db9f9f4df517c (diff) | |
Fixed errors introduced in 21f333bcefccc151d6439246f8203d609ab6ca79. Refs #17751
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/validators.py | 2 | ||||
| -rw-r--r-- | django/forms/fields.py | 16 |
2 files changed, 8 insertions, 10 deletions
diff --git a/django/core/validators.py b/django/core/validators.py index 322741be39..948ae28673 100644 --- a/django/core/validators.py +++ b/django/core/validators.py @@ -129,7 +129,7 @@ validate_email = EmailValidator() slug_re = re.compile(r'^[-a-zA-Z0-9_]+$') validate_slug = RegexValidator(slug_re, _("Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens."), 'invalid') -ipv4_re = re.compile(r'^\s*(25[0-5]|2[0-4]\d|[0-1]?\d?\d)(\.(25[0-5]|2[0-4]\d|[0-1]?\d?\d)){3}\s*$') +ipv4_re = 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}$') validate_ipv4_address = RegexValidator(ipv4_re, _('Enter a valid IPv4 address.'), 'invalid') diff --git a/django/forms/fields.py b/django/forms/fields.py index aa909a8aa5..277f0b093e 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -1096,9 +1096,10 @@ class IPAddressField(CharField): } default_validators = [validators.validate_ipv4_address] - def clean(self, value): - value = self.to_python(value).strip() - return super(IPAddressField, self).clean(value) + def to_python(self, value): + if value in EMPTY_VALUES: + return '' + return value.strip() class GenericIPAddressField(CharField): @@ -1111,16 +1112,13 @@ class GenericIPAddressField(CharField): self.default_error_messages['invalid'] = invalid_error_message super(GenericIPAddressField, self).__init__(*args, **kwargs) - def clean(self, value): - value = self.to_python(value).strip() - return super(GenericIPAddressField, self).clean(value) - def to_python(self, value): if value in validators.EMPTY_VALUES: return '' + value = value.strip() if value and ':' in value: - return clean_ipv6_address(value, - self.unpack_ipv4, self.error_messages['invalid']) + return clean_ipv6_address(value, + self.unpack_ipv4, self.error_messages['invalid']) return value |
