Commit b829ab9f authored by Stan Hu's avatar Stan Hu

Merge branch '334033-do-not-allow-deleting-branches-matching-url-encoded' into 'master'

Do not unescape branch name when deleting branch

See merge request gitlab-org/gitlab!73253
parents 173159dd f3e44598
...@@ -105,8 +105,7 @@ class Projects::BranchesController < Projects::ApplicationController ...@@ -105,8 +105,7 @@ class Projects::BranchesController < Projects::ApplicationController
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
def destroy def destroy
@branch_name = Addressable::URI.unescape(params[:id]) result = ::Branches::DeleteService.new(project, current_user).execute(params[:id])
result = ::Branches::DeleteService.new(project, current_user).execute(@branch_name)
respond_to do |format| respond_to do |format|
format.html do format.html do
......
...@@ -356,7 +356,7 @@ RSpec.describe Projects::BranchesController do ...@@ -356,7 +356,7 @@ RSpec.describe Projects::BranchesController do
context "valid branch name with encoded slashes" do context "valid branch name with encoded slashes" do
let(:branch) { "improve%2Fawesome" } let(:branch) { "improve%2Fawesome" }
it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response).to have_gitlab_http_status(:not_found) }
it { expect(response.body).to be_blank } it { expect(response.body).to be_blank }
end end
...@@ -396,10 +396,10 @@ RSpec.describe Projects::BranchesController do ...@@ -396,10 +396,10 @@ RSpec.describe Projects::BranchesController do
let(:branch) { 'improve%2Fawesome' } let(:branch) { 'improve%2Fawesome' }
it 'returns JSON response with message' do it 'returns JSON response with message' do
expect(json_response).to eql('message' => 'Branch was deleted') expect(json_response).to eql('message' => 'No such branch')
end end
it { expect(response).to have_gitlab_http_status(:ok) } it { expect(response).to have_gitlab_http_status(:not_found) }
end end
context 'invalid branch name, valid ref' do context 'invalid branch name, valid ref' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment