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

net/mail: Reading messages with empty bodies returns error (EOF) #15632

Closed
jspy opened this issue May 10, 2016 · 2 comments
Closed

net/mail: Reading messages with empty bodies returns error (EOF) #15632

jspy opened this issue May 10, 2016 · 2 comments

Comments

@jspy
Copy link

@jspy jspy commented May 10, 2016

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.

Example here:
https://play.golang.org/p/6AYSIRzlwE

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.

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented May 10, 2016

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?)

@bradfitz bradfitz added this to the Unplanned milestone May 10, 2016
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jun 29, 2016

Closing due to lack of reply.

@bradfitz bradfitz closed this Jun 29, 2016
@golang golang locked and limited conversation to collaborators Jun 29, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.