Commit 134420f2 authored by Stan Hu's avatar Stan Hu

Fix Content-Disposition hard-coded to attachments

Due to a regression in
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/24919,
Content-Disposition is hard-coded to `attachment` instead of `inline`.
We now use the argument `disposition` to fix that problem.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/57660
parent c470a779
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
module SendFileUpload module SendFileUpload
def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: 'attachment') def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: 'attachment')
if attachment if attachment
response_disposition = ::Gitlab::ContentDisposition.format(disposition: 'attachment', filename: attachment) response_disposition = ::Gitlab::ContentDisposition.format(disposition: disposition, filename: attachment)
# Response-Content-Type will not override an existing Content-Type in # Response-Content-Type will not override an existing Content-Type in
# Google Cloud Storage, so the metadata needs to be cleared on GCS for # Google Cloud Storage, so the metadata needs to be cleared on GCS for
......
...@@ -52,6 +52,23 @@ describe SendFileUpload do ...@@ -52,6 +52,23 @@ describe SendFileUpload do
end end
end end
context 'with inline image' do
let(:filename) { 'test.png' }
let(:params) { { disposition: 'inline', attachment: filename } }
it 'sends a file with inline disposition' do
# Notice the filename= is omitted from the disposition; this is because
# Rails 5 will append this header in send_file
expected_params = {
filename: 'test.png',
disposition: "inline; filename*=UTF-8''test.png"
}
expect(controller).to receive(:send_file).with(uploader.path, expected_params)
subject
end
end
context 'with attachment' do context 'with attachment' do
let(:filename) { 'test.js' } let(:filename) { 'test.js' }
let(:params) { { attachment: filename } } let(:params) { { attachment: filename } }
......
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