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

Add support for invalid chars #147

Closed
wants to merge 1 commit into from

Conversation

thiamsantos
Copy link

Motivation

We are receiving some email in which the filenames are not in utf-8. Causing the following exception:

** (FunctionClauseError) no function clause matching in Mail.Parsers.RFC2822.parse_quoted_string/2

The following arguments were given to Mail.Parsers.RFC2822.parse_quoted_string/2:

    # 1
    <<250, 100, 101, 95, 45, 95, 51, 49, 45, 48, 53, 45, 50, 50, 95, 45, 9, 95, 65, 98, 114, 105, 108, 46, 112, 100, 102, 46, 106, 112, 103, 34>>

    # 2
    "Boleto_Porto_Seguro_Sa"

    (mail 0.2.3) lib/mail/parsers/rfc_2822.ex:315: Mail.Parsers.RFC2822.parse_quoted_string/2
    (mail 0.2.3) lib/mail/parsers/rfc_2822.ex:297: Mail.Parsers.RFC2822.parse_structured_header_value/4
    (mail 0.2.3) lib/mail/parsers/rfc_2822.ex:200: Mail.Parsers.RFC2822.parse_headers/2
    (mail 0.2.3) lib/mail/parsers/rfc_2822.ex:21: Mail.Parsers.RFC2822.parse/1
    (elixir 1.13.1) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
    (elixir 1.13.1) lib/enum.ex:1593: Enum."-map/2-lists^map/1-0-"/2
    (mail 0.2.3) lib/mail/parsers/rfc_2822.ex:388: Mail.Parsers.RFC2822.parse_body/2

Changes proposed in this pull request

Ignore the unsupported characters when parsing the header value.

Honestly I don't know if the proposed changes make sense to be in the library, probably a proper charset handling as mentioned in #78 would be better.

@bcardarella
Copy link
Member

In order to add this to the RFC2822 parser we'd need confirmation that this doesn't violate the spec, or even better, it aligns us more closely with it. I don't have availability to review that at the moment but if you found out one way or the other that would be much appreciated!

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 this pull request may close these issues.

2 participants