Merge pull request #7736 from opf/fix/31205/attachment-disposition-filename

[31205] Fix attachment disposition for local files

[ci skip]
pull/7740/head
Oliver Günther 5 years ago committed by GitHub
commit f32663487b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      lib/api/helpers/attachment_renderer.rb
  2. 4
      spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb

@ -43,7 +43,7 @@ module API
redirect attachment.external_url.to_s
else
content_type attachment.content_type
header['Content-Disposition'] = attachment.content_disposition
header['Content-Disposition'] = "#{attachment.content_disposition}; filename=#{attachment.filename}"
env['api.format'] = :binary
attachment.diskfile.read
end

@ -287,14 +287,14 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j
context 'for a local text file' do
it_behaves_like 'for a local file' do
let(:mock_file) { FileHelpers.mock_uploaded_file name: 'foobar.txt' }
let(:content_disposition) { "inline" }
let(:content_disposition) { "inline; filename=foobar.txt" }
end
end
context 'for a local binary file' do
it_behaves_like 'for a local file' do
let(:mock_file) { FileHelpers.mock_uploaded_file name: 'foobar.dat', content_type: "application/octet-stream" }
let(:content_disposition) { "attachment" }
let(:content_disposition) { "attachment; filename=foobar.dat" }
end
end

Loading…
Cancel
Save