emersion / go-message

✉️ A streaming Go library for the Internet Message Format and mail messages
MIT License
373 stars 108 forks source link

Can't parse email where Message-ID has more than one "@" character #154

Open gsiehien opened 2 years ago

gsiehien commented 2 years ago

Hi!

I've noticed that if Message-ID (or any other header using msg-id) has more than one "@" character than parsing via parseMsgID() from header.go fails with:

missing '>' in msg-id

as it expects to consume() special chars in the fallowing order: < , @ , >

i.e.

Message-ID: <113c01d86b4a$53bb4230$fa9e45a$@appmanager@yahoo.com>

I'm not sure if using two or more "@" characters in msg-id is correct but I've already seen a few of this headers in the wild.

jugendhacker commented 1 year ago

According to https://www.rfc-editor.org/rfc/rfc5322.html#section-3.6.4 having more than one @ inside the msg-id isn't standard compliant and I would recommend fixing the broken implementation instead of accepting non standard stuff in this lib here.

mooijtech commented 1 year ago

For future reference, it's possible to call Text("Message-Id") from mail.Header instead of MessageID to not enter the parseMsgID function.

Microsoft not following specs/RFC as usual it seems: https://community.mailcow.email/d/701-multiple-at-in-message-id/3