mailibex
mailibex copied to clipboard
Parser issues on "From"
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\""}]
Ooops :) , I have a lot of work this week, so unfortunatly I will only fix this next week.
Hi @jschoch , are you still interested in getting this fixed?
Yup!
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