diff options
author | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-14 10:17:52 +0200 |
---|---|---|
committer | Robert Schilling <rschilling@student.tugraz.at> | 2014-08-14 10:17:52 +0200 |
commit | cbc90565b55d89704d64bc48db323b82b739a873 (patch) | |
tree | f6bb4220068bafab7a1b1a57d2b13631a553c4a2 /lib/api/merge_requests.rb | |
parent | 04ad197bcc41a26da2c2a80c5b4ffbfad2c296ee (diff) | |
download | gitlab-ce-cbc90565b55d89704d64bc48db323b82b739a873.tar.gz |
Do label validation for issues/merge requests API
Diffstat (limited to 'lib/api/merge_requests.rb')
-rw-r--r-- | lib/api/merge_requests.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index acca7cb6bad..0d765f9280e 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -76,6 +76,12 @@ module API authorize! :write_merge_request, user_project required_attributes! [:source_branch, :target_branch, :title] attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :target_project_id, :description] + + # Validate label names in advance + if validate_label_params(params) + return render_api_error!('Label names invalid', 405) + end + merge_request = ::MergeRequests::CreateService.new(user_project, current_user, attrs).execute if merge_request.valid? @@ -109,6 +115,12 @@ module API attrs = attributes_for_keys [:source_branch, :target_branch, :assignee_id, :title, :state_event, :description] merge_request = user_project.merge_requests.find(params[:merge_request_id]) authorize! :modify_merge_request, merge_request + + # Validate label names in advance + if validate_label_params(params) + return render_api_error!('Label names invalid', 405) + end + merge_request = ::MergeRequests::UpdateService.new(user_project, current_user, attrs).execute(merge_request) if merge_request.valid? |