Skip to content
Snippets Groups Projects
Commit 17380cf9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre Committed by GitLab Release Tools Bot
Browse files

Merge branch 'sh-fix-content-disposition-inline' into 'master'

Fix Content-Disposition hard-coded to attachments

Closes #57660

See merge request gitlab-org/gitlab-ce!25214

(cherry picked from commit a77a1e1b)

134420f2 Fix Content-Disposition hard-coded to attachments
parent 72defb15
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -3,7 +3,7 @@
module SendFileUpload
def send_upload(file_upload, send_params: {}, redirect_params: {}, attachment: nil, proxy: false, disposition: '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
# Google Cloud Storage, so the metadata needs to be cleared on GCS for
Loading
Loading
Loading
Loading
@@ -52,6 +52,23 @@ describe SendFileUpload do
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
let(:filename) { 'test.js' }
let(:params) { { attachment: filename } }
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment