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

Message parser chocking on charset-encoded addresses #7

Closed
xguerin opened this issue May 25, 2018 · 6 comments
Closed

Message parser chocking on charset-encoded addresses #7

xguerin opened this issue May 25, 2018 · 6 comments

Comments

@xguerin
Copy link

xguerin commented May 25, 2018

Hello there!

The message parser is giving me the following error:

mailio::message_error: Parsing failure of address or group at `<`.

Thrown from message.cpp:716, because of the following sender address:

 =?windows-1252?Q?Action_fran=E7aise_?=<contact@actionfrancaise.net>

My initial intuition is that MIME header encodings are not supported, but I might very well be wrong. I'll do a bit more digging, but any guidance would be appreciated :)

Thanks,

@xguerin
Copy link
Author

xguerin commented May 25, 2018

@karastojko
Copy link
Owner

karastojko commented May 25, 2018

Hello,
Thanks for trying mailio.

The issue is caused by missing space between the displayed name =?windows-1252?Q?Action_fran=E7aise_?= and the address itself <contact@actionfrancaise.net>. By RFC 5322 section 3.4 the space is required. If you add the missing space character in between, everything works fine.

However, I am aware that RFC requirement sometimes are too hard. There is so called strict mode which (when disabled) allows some of the mandatory requirements to be omitted. Unfortunately, the case with the address is not included. What I can do is take a look into the code and check if the fix can be made easily without breaking the existing functionality.

Also, the MIME formatter/parser recognizes only ASCII and UTF-8 formats of the address (i.e. the displayed name part). Other formats like Windows-1252 are not supported. Doing that would require dealing with various codecs, probably by using an external library.

Regards,

@xguerin
Copy link
Author

xguerin commented May 25, 2018

Thanks for looking into this. If I am not mistaken, according to RFC2822 section 3.4 the white space (CFWS) between the display-name and the angle-addr is optional.

What I can do is take a look into the code and check if the fix can be made easily without breaking the existing functionality.

Thanks. Concurrently, I wanted to toy with lemon and ragel to see if I can replicate the grammar specified in the RFC faithfully. If I get something usable I'll submit a PR.

@karastojko
Copy link
Owner

karastojko commented May 28, 2018

Actually, the bug exists only when Q encoding is used for the displayed name. In the case Action francaise<contact@actionfrancaise.net> or "Action francaise"<contact@actionfrancaise.net> (no space between the displayed name and the left bracket) everything works fine. I will investigate this further and let you know.

@karastojko
Copy link
Owner

@xguerin Take a look of the latest commit, tagged with version_0-16-1 on the master branch. It allows parsing of the Q encoded name/address in the case when no space exists between the displayed name and the address. Internal tests (which are far from being perfect) look fine, no existing feature should be broken.

@xguerin
Copy link
Author

xguerin commented May 30, 2018

Thanks ! That fixes it for that particular header.

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

No branches or pull requests

2 participants