Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

include attachments without a filename #1628

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/mail/message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1918,7 +1918,7 @@ def decode_body
# Returns true if this part is an attachment,
# false otherwise.
def attachment?
!!find_attachment
!!(content_disposition == "attachment" || find_attachment)
end

# Returns the attachment data if there is any
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
MIME-Version: 1.0 (Apple Message framework v730)
Content-Type: multipart/mixed; boundary=Apple-Mail-13-196941151
Message-Id: <9169D984-4E0B-45EF-82D4-8F5E53AD7012@example.com>
From: foo@example.com
Subject: testing
Date: Mon, 6 Jun 2005 22:21:22 +0200
To: blah@example.com


--Apple-Mail-13-196941151
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=ISO-8859-1;
delsp=yes;
format=flowed

This is the first part.

--Apple-Mail-13-196941151
Content-Type: text/x-ruby-script;
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;

puts "Hello, world!"
gets

--Apple-Mail-13-196941151--

6 changes: 6 additions & 0 deletions spec/mail/attachments_list_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ def check_decoded(actual, expected)
expect(mail.attachments.first.filename).to eq "ciële.txt"
end

it "should decode an attachment without a filename" do
mail = read_fixture('emails/attachment_emails/attachment_without_a_filename.eml')
expect(mail.attachments.length).to eq 1
expect(mail.attachments.first.filename).to eq nil
end

it "should find attachments inside parts with content-type message/rfc822" do
mail = read_fixture('emails/attachment_emails/attachment_message_rfc822.eml')
expect(mail.attachments.length).to eq 2
Expand Down
Loading