diff --git a/app/models/attachment.rb b/app/models/attachment.rb index 91ea010789..b32b6e9b60 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -81,7 +81,9 @@ class Attachment < ActiveRecord::Base end def content_disposition - inlineable? ? "inline" : "attachment; filename=#{self[:file]}" + # Do not use filename with attachment as this may break for Unicode files + # specifically when using S3 for attachments. + inlineable? ? "inline" : "attachment" end def visible?(user = User.current) diff --git a/spec/models/attachment_spec.rb b/spec/models/attachment_spec.rb index 62ffddd949..a7e85be1ae 100644 --- a/spec/models/attachment_spec.rb +++ b/spec/models/attachment_spec.rb @@ -290,8 +290,8 @@ describe Attachment, type: :model do before { binary_attachment.save! } it "should make S3 use content_disposition 'attachment; filename=...'" do - expect(binary_attachment.content_disposition).to eq "attachment; filename=textfile.txt.gz" - expect(binary_attachment.external_url.to_s).to include "response-content-disposition=attachment%3B%20filename%3Dtextfile.txt.gz" + expect(binary_attachment.content_disposition).to eq "attachment" + expect(binary_attachment.external_url.to_s).to include "response-content-disposition=attachment" end end end diff --git a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb index b65411c7b4..ccace9fe91 100644 --- a/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb +++ b/spec/requests/api/v3/attachments/attachment_resource_shared_examples.rb @@ -294,7 +294,7 @@ shared_examples 'an APIv3 attachment resource', type: :request, content_type: :j 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; filename=#{mock_file.original_filename}" } + let(:content_disposition) { "attachment" } end end