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

Fails to parse multipart message due to Content-Type header case sensitivity #160

Closed
alexpls opened this issue Feb 4, 2024 · 4 comments · Fixed by #161
Closed

Fails to parse multipart message due to Content-Type header case sensitivity #160

alexpls opened this issue Feb 4, 2024 · 4 comments · Fixed by #161

Comments

@alexpls
Copy link

alexpls commented Feb 4, 2024

Version

0.3.1

Test Case

  test "parses multipart emails with case insensitive Content-Type header" do
    raw =
      """
      Content-type: multipart/alternative; boundary=banana
      Mime-Version: 1.0

      --banana
      Content-Type: text/plain; charset=utf-8

      Hi

      --banana--
      """

    message =
      raw
      |> String.replace("\n", "\r\n")
      |> Mail.Parsers.RFC2822.parse()

    refute message.parts == [] # <-- I'd expect this to have one plain text part
  end

Expected Behavior

I can parse a multipart email whose content type header's case is Content-type.

Actual Behavior

I can't. Only emails where the header case is exactly Content-Type will be parsed.

Email headers aren't required to be case sensitive, and indeed I've observed mail servers in the wild sending messages with headers like Content-type instead of Content-Type. When this happens, elixir-mail fails to parse the message as multipart.

This relates to #148

@bcardarella
Copy link
Member

Can you try main ?

@alexpls
Copy link
Author

alexpls commented Feb 4, 2024

@bcardarella Latest commit on master branch works!

I've run my regression tests on emails that previously failed to have their Content-type parsed and they now work as expected.

Thanks for fixing this, and for responding so quickly!

@bcardarella
Copy link
Member

Don't thank me, thank the gummies I took two hours ago 🚀

@princemaple
Copy link
Contributor

Would be great to have a release!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants