-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: mail.ReadMessage in 1.20 cannot parse mbox headers #60332
Comments
I believe this is from the stricter textproto parser introduced in #53188 (side note, the robustness principle is a poor argument) cc @neild |
I can confirm. Debugging shows that due to the lack of a ":", the entire line is interpreted as a header field name, and so fails because it contains invalid header field characters. go/src/net/textproto/reader.go Line 727 in dbf9bf2
|
@gopherbot Please open backport to 1.20. This stopped working due to the changes in #53188, but those changes don't apply to net/mail. |
Backport issue(s) opened: #60874 (for 1.20). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
Change https://go.dev/cl/504416 mentions this issue: |
Change https://go.dev/cl/504881 mentions this issue: |
We parse mail messages using net/textproto. For #53188, we tightened up the bytes permitted by net/textproto to match RFC 7230. However, this package uses RFC 5322 which is more permissive. Restore the permisiveness we used to have, so that older code continues to work. For #58862 For #60332 Fixes #60874 Fixes #60875 Change-Id: I5437f5e18a756f6ca61c13c4d8ba727be73eff9a Reviewed-on: https://go-review.googlesource.com/c/go/+/504881 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Damien Neil <[email protected]>
We parse mail messages using net/textproto. For golang#53188, we tightened up the bytes permitted by net/textproto to match RFC 7230. However, this package uses RFC 5322 which is more permissive. Restore the permisiveness we used to have, so that older code continues to work. Fixes golang#58862 Fixes golang#60332 Change-Id: I5437f5e18a756f6ca61c13c4d8ba727be73eff9a Reviewed-on: https://go-review.googlesource.com/c/go/+/504416 Run-TryBot: Ian Lance Taylor <[email protected]> Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Damien Neil <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
What version of Go are you using (
go version
)?1.20.3
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
A change introduced in Go 1.20 prevents
mail.ReadMessage
from being able to handle messages preceded by a mbox header. A mbox header consists of aFrom
header (no colon) preceding the message content https://www.loc.gov/preservation/digital/formats/fdd/fdd000383.shtmlThis prevents mail.ReadMessage from being able to read single-message mbox files, or messages piped by MUAs like Mutt.
To reproduce: https://go.dev/play/p/lgqlLBsWBX8?v=goprev
What did you expect to see?
I did not expect my code to behave differently with a newer version of Go.
What did you see instead?
Due to a change in Go (presumably https://cs.opensource.google/go/go/+/42137704fca158f14c4aebff61b54ebeae788a4a), my Go program started reporting an error given identical input.
I believe that the prior behavior of ignoring mbox headers, even if unintended, should be restored in order to prevent programs that depended on it from breaking, to maintain its compatibility with previous versions, and to try and conform to the Robustness principle by handling a common malformed input.
The text was updated successfully, but these errors were encountered: