mirror of
https://github.com/discourse/discourse.git
synced 2025-03-15 20:35:50 +08:00
FIX: Email attachments with a size of 0 bytes caused error
This commit is contained in:
parent
67d5ce8ed1
commit
e84d88ddea
@ -1044,7 +1044,7 @@ module Email
|
||||
# create the upload for the user
|
||||
opts = { for_group_message: options[:is_group_message] }
|
||||
upload = UploadCreator.new(tmp, attachment.filename, opts).create_for(user.id)
|
||||
if upload&.valid?
|
||||
if upload.errors.empty?
|
||||
# try to inline images
|
||||
if attachment.content_type&.start_with?("image/")
|
||||
if raw[attachment.url]
|
||||
|
@ -597,6 +597,14 @@ describe Email::Receiver do
|
||||
MD
|
||||
end
|
||||
|
||||
it "works with removed attachments" do
|
||||
SiteSetting.authorized_extensions = "jpg"
|
||||
|
||||
expect { process(:removed_attachments) }.to change { topic.posts.count }
|
||||
post = topic.posts.last
|
||||
expect(post.uploads).to be_empty
|
||||
end
|
||||
|
||||
it "supports eml attachments" do
|
||||
SiteSetting.authorized_extensions = "eml"
|
||||
expect { process(:attached_eml_file) }.to change { topic.posts.count }
|
||||
|
53
spec/fixtures/emails/removed_attachments.eml
vendored
Normal file
53
spec/fixtures/emails/removed_attachments.eml
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
Return-Path: <discourse@bar.com>
|
||||
From: Foo Bar <discourse@bar.com>
|
||||
To: reply+4f97315cc828096c9cb34c6f1a0d6fe8@bar.com
|
||||
Date: Sat, 30 Jan 2016 01:10:11 +0100
|
||||
Message-ID: <38@foo.bar.mail>
|
||||
Content-type: multipart/related; boundary="_005_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_"; type="multipart/alternative"
|
||||
MIME-version: 1.0
|
||||
|
||||
--_005_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_
|
||||
Content-Type: multipart/alternative; boundary="_000_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_"
|
||||
|
||||
--_000_DM6PR06MB4524E804AE530DBCAB62D8D2EE780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
||||
ZWQgYnkgc2VuZGVyLiI+PC9zcGFuPjxvOnA+PC9vOnA+PC9wPgo8cCBjbGFzcz0iTXNvTm9ybWFs
|
||||
Ij48c3BhbiBzdHlsZT0iZm9udC1mYW1pbHk6JnF1b3Q7SGVsdmV0aWNhJnF1b3Q7LHNhbnMtc2Vy
|
||||
aWY7Ym9yZGVyOnNvbGlkIHdpbmRvd3RleHQgMS4wcHQ7cGFkZGluZzowaW4iPjxpbWcgd2lkdGg9
|
||||
IjQ1IiBoZWlnaHQ9IjQ1IiBzdHlsZT0id2lkdGg6LjQ2ODdpbjtoZWlnaHQ6LjQ2ODdpbiIgaWQ9
|
||||
Il94MDAwMF9pMTAyNSIgc3JjPSJjaWQ6aW1hZ2UwMDEuanBnQDAxRDU5NTYxLkIxMjQ0QzEwIiBh
|
||||
bHQ9IkltYWdlIHJlbW92ZWQgYnkgc2VuZGVyLiI+PC9zcGFuPjxzcGFuIHN0eWxlPSJmb250LWZh
|
||||
bWlseTomcXVvdDtIZWx2ZXRpY2EmcXVvdDssc2Fucy1zZXJpZiI+PG86cD48L286cD48L3NwYW4+
|
||||
PC9wPgo8L2Rpdj4KPC9ib2R5Pgo8L2h0bWw+
|
||||
--_000_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_--
|
||||
--_005_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_
|
||||
Content-Type: image/jpeg; name="~WRD349.jpg"
|
||||
Content-Description: ~WRD349.jpg
|
||||
Content-Disposition: inline; filename="~WRD349.jpg"; size=823; creation-date="Thu, 07 Nov 2019 17:48:28 GMT"; modification-date="Thu, 07 Nov 2019 17:48:28 GMT"
|
||||
Content-ID: <~WRD349.jpg>
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
|
||||
--_005_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_
|
||||
Content-Type: image/jpeg; name="image001.jpg"
|
||||
Content-Description: image001.jpg
|
||||
Content-Disposition: inline; filename="image001.jpg"; size=359; creation-date="Thu, 07 Nov 2019 17:51:31 GMT"; modification-date="Thu, 07 Nov 2019 17:51:31 GMT"
|
||||
Content-ID: <image001.jpg@01D59561.B1244C10>
|
||||
Content-Transfer-Encoding: base64
|
||||
|
||||
|
||||
--_005_DM6PR06MB4524E804AE530DBCAB62D8D2EE780DM6PR06MB4524namp_--
|
Loading…
x
Reference in New Issue
Block a user