forms: fix validation of repository URLs in layer edit form

Anchor the regex so it must match the entire string, and disallow
spaces.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-10-01 15:05:08 +13:00
parent e4c6844c50
commit f10c4db361

View File

@ -128,7 +128,7 @@ class EditLayerForm(StyledModelForm):
def clean_vcs_url(self):
url = self.cleaned_data['vcs_url'].strip()
val = RegexValidator(regex=r'[a-z]+://.*', message='Please enter a valid repository URL, e.g. git://server.name/path')
val = RegexValidator(regex=r'^[a-z]+://[^ ]+$', message='Please enter a valid repository URL, e.g. git://server.name/path')
val(url)
return url