I spotted some possible problems.
These findings are based on simple heuristics. If a finding appears wrong, briefly reply here saying so. Otherwise, please address any problems and update the GitHub PR. When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above.
Possible problems detected:
1. Are you using markdown? Markdown should not be used to augment text in the commit message.
The commit title and commit message body come from the GitHub PR title and description, and must be edited in the GitHub web interface (not via git). For instructions, see [here](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages).
(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net/mail: enhance address parser to include IPv6 address tags
The new domain-literal support missed that IPv6 addresses need to be
prefixed with `IPv6:`.
The IPv6-address-literal Specification, defined in RFC 5321 Section 4.1.3,
outlines the format for IPv6 address literals:
https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3
Good news, the IANA has registered no other Address Literal Tags.
Updates #60206
diff --git a/src/net/mail/message.go b/src/net/mail/message.go
index 21b075e..3c5adbf 100644
--- a/src/net/mail/message.go
+++ b/src/net/mail/message.go
@@ -751,8 +751,13 @@
return "", errors.New("mail: unclosed domain-literal")
}
- // Check if the domain literal is an IP address
- if net.ParseIP(dtext) == nil {
+ if addr, ok := strings.CutPrefix(dtext, "IPv6:"); ok {
+ if len(net.ParseIP(addr)) != net.IPv6len {
+ return "", fmt.Errorf("mail: invalid IPv6 address in domain-literal: %q", dtext)
+ }
+
+ } else if len(net.ParseIP(dtext).To4()) != net.IPv4len {
+ // Check if the domain literal is an IP address
return "", fmt.Errorf("mail: invalid IP address in domain-literal: %q", dtext)
}
diff --git a/src/net/mail/message_test.go b/src/net/mail/message_test.go
index dad9c36..0ea8cea 100644
--- a/src/net/mail/message_test.go
+++ b/src/net/mail/message_test.go
@@ -395,6 +395,7 @@
22: {"<jdoe@[[192.168.0.1]>", "bad character in domain-literal"},
23: {"<jdoe@[192.168.0.1>", "unclosed domain-literal"},
24: {"<jdoe@[256.0.0.1]>", "invalid IP address in domain-literal"},
+ 25: {"<jdoe@[fd42::de:ad:be:ef]>", "invalid IP address in domain-literal"},
}
for i, tc := range mustErrTestCases {
@@ -825,6 +826,20 @@
Address: "jdoe@[192.168.0.1]",
}},
},
+ // IPv6 Domain-literal
+ {
+ `jdoe@[IPv6:fd42::dead:beef:1234]`,
+ []*Address{{
+ Address: "jdoe@[IPv6:fd42::dead:beef:1234]",
+ }},
+ },
+ {
+ `John Doe <jdoe@[IPv6:fd42::dead:beef:1234]>`,
+ []*Address{{
+ Name: "John Doe",
+ Address: "jdoe@[IPv6:fd42::dead:beef:1234]",
+ }},
+ },
}
for _, test := range tests {
if len(test.exp) == 1 {
@@ -989,6 +1004,20 @@
Address: "jdoe@[192.168.0.1]",
}},
},
+ // IPv6 Domain-literal
+ {
+ `jdoe@[IPv6:fd42::dead:beef:1234]`,
+ []*Address{{
+ Address: "jdoe@[IPv6:fd42::dead:beef:1234]",
+ }},
+ },
+ {
+ `John Doe <jdoe@[IPv6:fd42::dead:beef:1234]>`,
+ []*Address{{
+ Name: "John Doe",
+ Address: "jdoe@[IPv6:fd42::dead:beef:1234]",
+ }},
+ },
}
ap := AddressParser{WordDecoder: &mime.WordDecoder{
@@ -1104,6 +1133,15 @@
&Address{Name: "Bob", Address: "bob@[192.168.0.1]"},
`"Bob" <bob@[192.168.0.1]>`,
},
+ // IPv6 Domain-literal
+ {
+ &Address{Address: "bob@[IPv6:fd42::dead:beef:1234]"},
+ "<bob@[IPv6:fd42::dead:beef:1234]>",
+ },
+ {
+ &Address{Name: "Bob", Address: "bob@[IPv6:fd42::dead:beef:1234]"},
+ `"Bob" <bob@[IPv6:fd42::dead:beef:1234]>`,
+ },
}
for _, test := range tests {
s := test.addr.String()
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
I spotted some possible problems.
These findings are based on simple heuristics. If a finding appears wrong, briefly reply here saying so. Otherwise, please address any problems and update the GitHub PR. When complete, mark this comment as 'Done' and click the [blue 'Reply' button](https://go.dev/wiki/GerritBot#i-left-a-reply-to-a-comment-in-gerrit-but-no-one-but-me-can-see-it) above.
Possible problems detected:
1. Are you using markdown? Markdown should not be used to augment text in the commit message.The commit title and commit message body come from the GitHub PR title and description, and must be edited in the GitHub web interface (not via git). For instructions, see [here](https://go.dev/wiki/GerritBot/#how-does-gerritbot-determine-the-final-commit-message). For guidelines on commit messages for the Go project, see [here](https://go.dev/doc/contribute#commit_messages).
(In general for Gerrit code reviews, the change author is expected to [log in to Gerrit](https://go-review.googlesource.com/login/) with a Gmail or other Google account and then close out each piece of feedback by marking it as 'Done' if implemented as suggested or otherwise reply to each review comment. See the [Review](https://go.dev/doc/contribute#review) section of the Contributing Guide for details.)
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
} else if len(net.ParseIP(dtext).To4()) != net.IPv4len {} else if net.ParseIP(dtext).To4() == nil {
// Check if the domain literal is an IP addressThis comment seems misplaced now.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
} else if len(net.ParseIP(dtext).To4()) != net.IPv4len {} else if net.ParseIP(dtext).To4() == nil {
Done
// Check if the domain literal is an IP addressThis comment seems misplaced now.
Yeah, the comment was ahead of the "if" before, but when it changed to an "else if", putting it above the line feels even more wrong, as it is in the wrong code block.
With a little bit of Repeat Yourself, we could copy the "return" below, and then get a plain "if" again, which allows the comment to return to ahead of the "if".
Or, I could rework the comment to suggest that the condition is true in this block, like "do not accept any non IPv4 addresses" or such.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Check if the domain literal is an IP addressCassy FoeschThis comment seems misplaced now.
Yeah, the comment was ahead of the "if" before, but when it changed to an "else if", putting it above the line feels even more wrong, as it is in the wrong code block.
With a little bit of Repeat Yourself, we could copy the "return" below, and then get a plain "if" again, which allows the comment to return to ahead of the "if".
Or, I could rework the comment to suggest that the condition is true in this block, like "do not accept any non IPv4 addresses" or such.
It seems OK to me to put the comment before the strings.CutPrefix call. It is correctly saying that we are checking if the domain literal is an IP address (an IPv4 or an IPv6 address). Or rewriting the comment is fine if that seems better.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Check if the domain literal is an IP addressCassy FoeschThis comment seems misplaced now.
Ian Lance TaylorYeah, the comment was ahead of the "if" before, but when it changed to an "else if", putting it above the line feels even more wrong, as it is in the wrong code block.
With a little bit of Repeat Yourself, we could copy the "return" below, and then get a plain "if" again, which allows the comment to return to ahead of the "if".
Or, I could rework the comment to suggest that the condition is true in this block, like "do not accept any non IPv4 addresses" or such.
It seems OK to me to put the comment before the strings.CutPrefix call. It is correctly saying that we are checking if the domain literal is an IP address (an IPv4 or an IPv6 address). Or rewriting the comment is fine if that seems better.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
😐oof. I’ve fixed the wrong-sense on the To4 conditional.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +2 |
Note that since Go1.23, net/mail has wrongly accepted [ipv6] without the IPv6: prefix.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net/mail: enhance address parser to include IPv6 address tags```suggestion
net/mail: parse ipv6 in addresses according to RFC 5321
```
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net/mail: enhance address parser to include IPv6 address tags```suggestion
net/mail: parse ipv6 in addresses according to RFC 5321
```
I seem to have trouble making this change. Here, gerrit does not recognize that @googlemail.com is also @gmail.com, and while I have changed the title of the Github title (as I read I should do on the howto), it does not seem to have changed here. 😐
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
A rebase on fresh branch finally updated title.
net/mail: enhance address parser to include IPv6 address tagsCassondra Foesch```suggestion
net/mail: parse ipv6 in addresses according to RFC 5321
```
I seem to have trouble making this change. Here, gerrit does not recognize that @googlemail.com is also @gmail.com, and while I have changed the title of the Github title (as I read I should do on the howto), it does not seem to have changed here. 😐
Done
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +2 |
| Commit-Queue | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net/mail: parse ipv6 in addresses according to RFC 5321.
The new domain-literal support missed that IPv6 addresses need to be
prefixed with "IPv6:".
The IPv6-address-literal Specification, defined in RFC 5321 Section 4.1.3,
outlines the format for IPv6 address literals:
https://datatracker.ietf.org/doc/html/rfc5321#section-4.1.3
Good news, the IANA has registered no other Address Literal Tags.
Updates #60206
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |