Skip to content

Commit

Permalink
Update test to handle content disposition with no properties
Browse files Browse the repository at this point in the history
Addresses issue in DockYard#154
  • Loading branch information
andrewtimberlake committed Aug 10, 2023
1 parent db7b4e7 commit 5154618
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/mail.ex
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ defmodule Mail do
case Mail.Message.is_attachment?(message) do
true ->
filename =
case Mail.Message.get_header(message, :content_disposition) do
case List.wrap(Mail.Message.get_header(message, :content_disposition)) do
["attachment" | properties] ->
Enum.find_value(properties, "Unknown", fn {key, value} ->
key == "filename" && value
Expand Down
3 changes: 3 additions & 0 deletions test/mail_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ defmodule MailTest do
"attachment"
])
|> Mail.Message.put_header(:content_transfer_encoding, :base64)
# We render and parse so we have the attachment with no properties
|> Mail.render()
|> Mail.parse()

[attachment | _] = Mail.get_attachments(mail)
assert attachment == file
Expand Down

0 comments on commit 5154618

Please sign in to comment.