-
Notifications
You must be signed in to change notification settings - Fork 18k
net/mail: fix EOF error while reading header-only message #47898
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
Conversation
This PR (HEAD: 249ced1) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/344269 to see it. Tip: You can toggle comments from me using the |
Message from Go Bot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
This PR (HEAD: 90fd186) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/344269 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 747963b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/344269 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 4dbbbc4) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/344269 to see it. Tip: You can toggle comments from me using the |
This PR (HEAD: 356a942) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/344269 to see it. Tip: You can toggle comments from me using the |
It would be great if someone provides an update on this PR. I am facing the same issue. |
@praveenk007 for now you can use the following function in your code: import (
"bufio"
"io"
"net/mail"
"net/textproto"
)
// ReadMessage reads a message from r.
// The headers are parsed, and the body of the message will be available
// for reading from msg.Body.
func ReadMessage(r io.Reader) (msg *mail.Message, err error) {
tp := textproto.NewReader(bufio.NewReader(r))
hdr, err := tp.ReadMIMEHeader()
if err != nil && (err != io.EOF || len(hdr) == 0) {
return nil, err
}
return &mail.Message{
Header: mail.Header(hdr),
Body: tp.R,
}, nil
} |
@praveenk007 We don't use GitHub for code review. Very few people will see your comment. Comments on this change should go to http://go.dev/cl/344269. Thanks. |
Message from Ian Lance Taylor: Patch Set 6: Run-TryBot+1 Auto-Submit+1 Code-Review+2 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 6: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 6: TryBot-Result-1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Ian Lance Taylor: Patch Set 8: Patch Set 7 was rebased Copied Votes:
Outdated Votes:
Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Ian Lance Taylor: Patch Set 8: Run-TryBot+1 Code-Review+2 Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 8: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 8: TryBot-Result+1 (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Cherry Mui: Patch Set 8: Code-Review+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Dmitri Shuralyov: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Ian Lance Taylor: Patch Set 8: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Ian Lance Taylor: Patch Set 9: Patch Set 8 was rebased Copied Votes:
Outdated Votes:
Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Ian Lance Taylor: Patch Set 9: Auto-Submit+1 Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Message from Gopher Robot: Patch Set 9: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/344269. |
Check if any header found in case of EOF to recognize header-only messages and if so, return a Message with the found headers and a body from the reader which is already empty. Fixes #33823. Change-Id: I2f0396b08e9be4e6c89c212ce62b9c87b5f63123 GitHub-Last-Rev: 356a942 GitHub-Pull-Request: #47898 Reviewed-on: https://go-review.googlesource.com/c/go/+/344269 Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]>
This PR is being closed because golang.org/cl/344269 has been merged. |
Check if any header found in case of EOF to recognize header-only
messages and if so, return a Message with the found headers
and a body from the reader which is already empty.
Fixes #33823.