RFC 5322 has a section 4.4 where it says that address-list could
have "null" members: "That is, there could be two or more commas in
such a list with nothing in between them, or commas at the beginning
or end of the list." This change handles such a case so that mail
clients using this method on actual email messages get a reasonable
return value when they parse email.
Fixes #36959
Change-Id: I3ca240969935067262e3d751d376a06db1fef2a2
GitHub-Last-Rev:
b96a9f2c075dfd67c3ff7b8ae0c12e12035f0da0
GitHub-Pull-Request: golang/go#36966
Reviewed-on: https://go-review.googlesource.com/c/go/+/217377
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
var list []*Address
for {
p.skipSpace()
+
+ // allow skipping empty entries (RFC5322 obs-addr-list)
+ if p.consume(',') {
+ continue
+ }
+ if p.empty() {
+ break
+ }
+
addrs, err := p.parseAddress(true)
if err != nil {
return nil, err
},
},
},
+ // RFC5322 4.4 obs-addr-list
+ {
+ ` , joe@where.test,,John <jdoe@one.test>,`,
+ []*Address{
+ {
+ Name: "",
+ Address: "joe@where.test",
+ },
+ {
+ Name: "John",
+ Address: "jdoe@one.test",
+ },
+ },
+ },
{
`Group1: <addr1@example.com>;, Group 2: addr2@example.com;, John <addr3@example.com>`,
[]*Address{