mirror of
https://github.com/golang/go.git
synced 2026-06-28 03:40:37 +00:00
crypto/x509: stricter email parsing
Reject parsing certificates which contain multiple unescaped @s. Change-Id: I68460cc2f763aaf5b7953fee3c55b0680d3ff937 Reviewed-on: https://go-review.googlesource.com/c/go/+/769160 Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
122eb7d035
commit
62caa6db3d
2 changed files with 7 additions and 1 deletions
|
|
@ -2299,6 +2299,7 @@ var rfc2821Tests = []struct {
|
|||
{".foo.bar@example.com", "", ""},
|
||||
{"foo.bar.@example.com", "", ""},
|
||||
{"|{}?'@example.com", "|{}?'", "example.com"},
|
||||
{"a@b@c.com", "", ""},
|
||||
|
||||
// Examples from RFC 3696
|
||||
{"Abc\\@def@example.com", "Abc@def", "example.com"},
|
||||
|
|
|
|||
|
|
@ -388,7 +388,12 @@ func parseRFC2821Mailbox(in string) (mailbox rfc2821Mailbox, ok bool) {
|
|||
// The RFC species a format for domains, but that's known to be
|
||||
// violated in practice so we accept that anything after an '@' is the
|
||||
// domain part.
|
||||
if _, ok := domainToReverseLabels(in); !ok {
|
||||
if !domainNameValid(in, false) {
|
||||
return mailbox, false
|
||||
}
|
||||
|
||||
// Reject domain names containing @.
|
||||
if strings.ContainsRune(in, '@') {
|
||||
return mailbox, false
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue