mailibex icon indicating copy to clipboard operation
mailibex copied to clipboard

Parser issues on "From"

Open jschoch opened this issue 8 years ago • 4 comments

Great library btw!!!!

The following is parsed incorrectly

X-Mailer: MIME::Lite 3.028 (F2.82; T1.31; A2.08; B3.13; Q3.13)
From: "craigslist - automated message, do not reply" <[email protected]>
To: [email protected]
Subject: craigslist.org:

here is the resulting parsed terms

[%MimeMail.Address{address: "\"craigslist - automated message", name: nil}, %MimeMail.Address{address: "[email protected]", name: "do not reply\""}]

jschoch avatar May 10 '16 21:05 jschoch

Ooops :) , I have a lot of work this week, so unfortunatly I will only fix this next week.

awetzel avatar May 11 '16 08:05 awetzel

Hi @jschoch , are you still interested in getting this fixed?

heri16 avatar Jul 20 '16 15:07 heri16

Yup!

jschoch avatar Jul 21 '16 22:07 jschoch

Wow, who knew parsing email was such a kludge. I spent a ton of time reading the RFC's and trying different approaches.

The problem is when the from header has something like "hello there, i'm cool" <[email protected]> the headers get split via

https://github.com/awetzel/mailibex/blob/89321330b4e46c58938182a63d047dad95b2c15d/lib/mimemail_headers.ex#L20

that should be

data |> String.strip |> String.split(~r/(,)(?=(?:[^"]|"[^"]*")*$)/) |> Enum.map(&MimeMail.Address.decode/1)

This allows for the very oddball multiple from which the RFC's allow.

Wondering if someone can take a look and see if this works. It may be good to only do this with the From: header

jschoch avatar Jan 21 '17 23:01 jschoch