diff --git a/pagure/forms.py b/pagure/forms.py index 15b7393..54f11be 100644 --- a/pagure/forms.py +++ b/pagure/forms.py @@ -29,6 +29,7 @@ import wtforms import pagure.lib from pagure.config import config as pagure_config +from pagure.utils import urlpattern STRICT_REGEX = '^[a-zA-Z0-9-_]+$' @@ -128,7 +129,10 @@ class ProjectFormSimplified(PagureForm): ) url = wtforms.TextField( 'URL', - [wtforms.validators.optional()] + [ + wtforms.validators.optional(), + wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE), + ] ) avatar_email = wtforms.TextField( 'Avatar email', @@ -485,7 +489,10 @@ class AddPullRequestFlagFormV1(PagureForm): comment = wtforms.TextAreaField( 'Comment', [wtforms.validators.Required()]) url = wtforms.TextField( - 'URL', [wtforms.validators.Required()]) + 'URL', [ + wtforms.validators.Required(), + wtforms.validators.Regexp(urlpattern, flags=re.IGNORECASE), + ]) uid = wtforms.TextField( 'UID', [wtforms.validators.optional()]) diff --git a/pagure/ui/repo.py b/pagure/ui/repo.py index 02d3b68..a0d8f00 100644 --- a/pagure/ui/repo.py +++ b/pagure/ui/repo.py @@ -1273,6 +1273,11 @@ def update_project(repo, username=None, namespace=None): except SQLAlchemyError as err: # pragma: no cover flask.g.session.rollback() flask.flash(str(err), 'error') + else: + for field in form.errors: + flask.flash( + 'Field "%s" errored with errors: %s' % ( + field, ', '.join(form.errors[field])), 'error') return flask.redirect(flask.url_for( 'ui_ns.view_settings', username=username, repo=repo.name,