-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.20] net/mail: permit more characters in mail headers
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]>
- Loading branch information
1 parent
c32f1af
commit b59efe6
Showing
2 changed files
with
78 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,34 @@ So, "Hello". | |
}, | ||
body: "This is a message just to say hello.\nSo, \"Hello\".\n", | ||
}, | ||
{ | ||
// RFC 5322 permits any printable ASCII character, | ||
// except colon, in a header key. Issue #58862. | ||
in: `From: [email protected] | ||
Custom/Header: v | ||
Body | ||
`, | ||
header: Header{ | ||
"From": []string{"[email protected]"}, | ||
"Custom/Header": []string{"v"}, | ||
}, | ||
body: "Body\n", | ||
}, | ||
{ | ||
// RFC 4155 mbox format. We've historically permitted this, | ||
// so we continue to permit it. Issue #60332. | ||
in: `From [email protected] Mon Jun 19 00:00:00 2023 | ||
From: [email protected] | ||
Hello, gophers! | ||
`, | ||
header: Header{ | ||
"From": []string{"[email protected]"}, | ||
"From [email protected] Mon Jun 19 00": []string{"00:00 2023"}, | ||
}, | ||
body: "Hello, gophers!\n", | ||
}, | ||
} | ||
|
||
func TestParsing(t *testing.T) { | ||
|