Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
net/mail: Reading messages with empty bodies returns error (EOF) #15632
go version go1.6.1 linux/amd64
Can't read mail messages which are empty. ReadMessage() returns with err = "EOF"
This is due to net/textproto/ReadMIMEHeader -> readContinuedLineSlice() returning an EOF.
Note that mail clients which produce these mail messages are available in the wild, and this specific bug/implementation choice was produced by:
X-Mailer: Apple Mail (2.3124)
A simple fix would probably be to let ReadMIMEHeader in net/textproto/reader.go check if the buffer is empty or not around line 480 instead of just seeing if len(kv) == 0.
I don't think this is a bug. It looks like it's working as intended: the headers are truncated if it doesn't end with a blank line, so it's reporting an error.
Maybe it should return UnexpectedEOF instead of EOF, but not success.
How did you get that input? (Apple Mail, yes, but how did you extract it for the unit test?)