mirror of
https://github.com/ansible/awx.git
synced 2026-05-12 11:57:37 -02:30
Fix LDAPServerURIField number in domain
- Bug: API error if LDAPServerURIField contains a number in the top level domain - Add custom regex in LDAPServerURIField class that is passed to django URLValidator - The custom regex allows for numbers to be present in the top level domain - Unit tests check that valid URIs pass through URLValidator, and that invalid URIs raise the correct exception - Related to issue #3646
This commit is contained in:
@@ -121,11 +121,14 @@ class URLField(CharField):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
schemes = kwargs.pop('schemes', None)
|
||||
regex = kwargs.pop('regex', None)
|
||||
self.allow_plain_hostname = kwargs.pop('allow_plain_hostname', False)
|
||||
super(URLField, self).__init__(**kwargs)
|
||||
validator_kwargs = dict(message=_('Enter a valid URL'))
|
||||
if schemes is not None:
|
||||
validator_kwargs['schemes'] = schemes
|
||||
if regex is not None:
|
||||
validator_kwargs['regex'] = regex
|
||||
self.validators.append(URLValidator(**validator_kwargs))
|
||||
|
||||
def to_representation(self, value):
|
||||
|
||||
Reference in New Issue
Block a user