mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 08:54:54 +08:00
FIX: Use ActionDispatch::Http::ContentDisposition for uploads content-disposition (#10108)
See https://meta.discourse.org/t/broken-pipe-error-when-uploading-to-a-s3-clone-a-pdf-with-a-name-containing-e-i-etc/155414 When setting content-disposition for attachment, use the ContentDisposition class to format it. This handles filenames with weird characters and localization (accented characters) correctly.
This commit is contained in:
@ -44,7 +44,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
||||
let(:uploaded_file) { file_from_fixtures("small.pdf", "pdf") }
|
||||
|
||||
it "adds an attachment content-disposition with the original filename" do
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"", content_type: "application/pdf" }
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"; filename*=UTF-8''#{original_filename}", content_type: "application/pdf" }
|
||||
s3_helper.expects(:upload).with(uploaded_file, kind_of(String), upload_opts.merge(disp_opts)).returns(["path", "etag"])
|
||||
upload = build_upload
|
||||
store.store_upload(uploaded_file, upload)
|
||||
@ -56,7 +56,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
||||
let(:uploaded_file) { file_from_fixtures("small.mp4", "media") }
|
||||
|
||||
it "adds an attachment content-disposition with the original filename" do
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"", content_type: "application/mp4" }
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"; filename*=UTF-8''#{original_filename}", content_type: "application/mp4" }
|
||||
s3_helper.expects(:upload).with(uploaded_file, kind_of(String), upload_opts.merge(disp_opts)).returns(["path", "etag"])
|
||||
upload = build_upload
|
||||
store.store_upload(uploaded_file, upload)
|
||||
@ -68,7 +68,7 @@ RSpec.describe 'Multisite s3 uploads', type: :multisite do
|
||||
let(:uploaded_file) { file_from_fixtures("small.mp3", "media") }
|
||||
|
||||
it "adds an attachment content-disposition with the original filename" do
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"", content_type: "audio/mpeg" }
|
||||
disp_opts = { content_disposition: "attachment; filename=\"#{original_filename}\"; filename*=UTF-8''#{original_filename}", content_type: "audio/mpeg" }
|
||||
s3_helper.expects(:upload).with(uploaded_file, kind_of(String), upload_opts.merge(disp_opts)).returns(["path", "etag"])
|
||||
upload = build_upload
|
||||
store.store_upload(uploaded_file, upload)
|
||||
|
Reference in New Issue
Block a user