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

Fix quoted-printable encoding #82

Merged
merged 1 commit into from Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/mail/encoder.ex
Expand Up @@ -8,7 +8,7 @@ defmodule Mail.Encoder do
@spec encoder_for(encoding :: String.t | atom) :: atom
def encoder_for(encoding) when is_atom(encoding) do
encoding
|> Atom.to_string()
|> normalize()
|> encoder_for()
end

Expand All @@ -27,4 +27,8 @@ defmodule Mail.Encoder do

@spec decode(data :: binary, encoding :: String.t) :: binary
def decode(data, encoding), do: encoder_for(encoding).decode(data)

defp normalize(:quoted_printable), do: normalize(:"quoted-printable")
defp normalize(encoding) when is_atom(encoding), do: Atom.to_string(encoding)
defp normalize(encoding) when is_binary(encoding), do: encoding
end
4 changes: 2 additions & 2 deletions test/fixtures/recursive-part-rendering.eml
Expand Up @@ -4,11 +4,11 @@ Content-Type: multipart/alternative; boundary="foobar"
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable

Hello there!
Hello there! 1 + 1 =3D 2

--foobar
Content-Type: text/html
Content-Transfer-Encoding: quoted-printable

<h1>Hello there!</h1>
<a href=3D"/">Hello there! 1 + 1 =3D 2</a>
--foobar--
4 changes: 2 additions & 2 deletions test/mail/renderers/rfc_2822_test.exs
Expand Up @@ -68,8 +68,8 @@ defmodule Mail.Renderers.RFC2822Test do
end

test "renders each part recursively" do
sub_part_1 = Mail.Message.build_text("Hello there!")
sub_part_2 = Mail.Message.build_html("<h1>Hello there!</h1>")
sub_part_1 = Mail.Message.build_text("Hello there! 1 + 1 = 2")
sub_part_2 = Mail.Message.build_html(~s|<a href="/">Hello there! 1 + 1 = 2</a>|)

part =
Mail.build_multipart()
Expand Down