From 8413286b1241cd4fd3763c6890780a02760cd175 Mon Sep 17 00:00:00 2001 From: Clement Verna Date: Aug 21 2017 09:06:04 +0000 Subject: Replace common logic with helper function to check link url Signed-off-by: Clement Verna --- diff --git a/pagure/api/issue.py b/pagure/api/issue.py index d5d0232..38f8198 100644 --- a/pagure/api/issue.py +++ b/pagure/api/issue.py @@ -137,6 +137,7 @@ def _check_link_custom_field(field, links): raise pagure.exceptions.APIError( 400, error_code=APIERROR.EINVALIDISSUEFIELD_LINK) + @API.route('//new_issue', methods=['POST']) @API.route('///new_issue', methods=['POST']) @API.route('/fork///new_issue', methods=['POST']) @@ -1184,13 +1185,7 @@ def api_update_custom_field( key = fields[field] value = flask.request.form.get('value') if value: - if key.key_type == 'link': - links = value.split(',') - for link in links: - link = link.replace(' ', '') - if not urlpattern.match(link): - raise pagure.exceptions.APIError( - 400, error_code=APIERROR.EINVALIDISSUEFIELD_LINK) + _check_link_custom_field(key, value) try: message = pagure.lib.set_custom_key_value( SESSION, issue, key, value)