diff options
author | Stan Hu <stanhu@gmail.com> | 2018-09-25 16:35:10 +0000 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-09-25 16:35:10 +0000 |
commit | 0920342094ae07d7225b42cf23cf9637076d2b25 (patch) | |
tree | b42ce963207738b88566a578dc0f3e7b9d2bf3bd /spec | |
parent | 45b365b0e5abdb86ff6ac23b00578d5398134af9 (diff) | |
parent | 1fcc7f9ba23a5ca02773e080ccb66f37435150ff (diff) | |
download | gitlab-ce-0920342094ae07d7225b42cf23cf9637076d2b25.tar.gz |
Merge branch 'fa-handle_invalid_utf8_errors' into 'master'
Render 412 when invalid UTF-8 is passed as parameter
See merge request gitlab-org/gitlab-ce!21774
Diffstat (limited to 'spec')
-rw-r--r-- | spec/controllers/application_controller_spec.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index fbf116e533b..7202cee04ea 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -694,4 +694,38 @@ describe ApplicationController do expect(response).to have_gitlab_http_status(403) end end + + context 'when invalid UTF-8 parameters are received' do + controller(described_class) do + def index + params[:text].split(' ') + + render json: :ok + end + end + + before do + sign_in user + end + + context 'html' do + it 'renders 412' do + get :index, text: "hi \255" + + expect(response).to have_gitlab_http_status(412) + expect(response).to render_template :precondition_failed + end + end + + context 'js' do + it 'renders 412' do + get :index, text: "hi \255", format: :js + + json_response = JSON.parse(response.body) + + expect(response).to have_gitlab_http_status(412) + expect(json_response['error']).to eq('Invalid UTF-8') + end + end + end end |