mirror of
https://github.com/golang/go
synced 2024-11-18 05:54:49 -07:00
net/mail: allow empty quoted string name in address again
CL 12905 disallowed "Bob" <""@example.com> but inadvertently also disallowed "" <bob@example.com>. Move the empty string check to apply only in the addr-spec. Fixes #14866. Change-Id: Ia0b7a1a32810aa78157ae77bd0130b78154c460d Reviewed-on: https://go-review.googlesource.com/32176 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
parent
07e72666ec
commit
2bafbe11b1
@ -346,6 +346,9 @@ func (p *addrParser) consumeAddrSpec() (spec string, err error) {
|
|||||||
// quoted-string
|
// quoted-string
|
||||||
debug.Printf("consumeAddrSpec: parsing quoted-string")
|
debug.Printf("consumeAddrSpec: parsing quoted-string")
|
||||||
localPart, err = p.consumeQuotedString()
|
localPart, err = p.consumeQuotedString()
|
||||||
|
if localPart == "" {
|
||||||
|
err = errors.New("mail: empty quoted string in addr-spec")
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// dot-atom
|
// dot-atom
|
||||||
debug.Printf("consumeAddrSpec: parsing dot-atom")
|
debug.Printf("consumeAddrSpec: parsing dot-atom")
|
||||||
@ -463,9 +466,6 @@ Loop:
|
|||||||
i += size
|
i += size
|
||||||
}
|
}
|
||||||
p.s = p.s[i+1:]
|
p.s = p.s[i+1:]
|
||||||
if len(qsb) == 0 {
|
|
||||||
return "", errors.New("mail: empty quoted-string")
|
|
||||||
}
|
|
||||||
return string(qsb), nil
|
return string(qsb), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,6 +315,16 @@ func TestAddressParsing(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Issue 14866
|
||||||
|
{
|
||||||
|
`"" <emptystring@example.com>`,
|
||||||
|
[]*Address{
|
||||||
|
{
|
||||||
|
Name: "",
|
||||||
|
Address: "emptystring@example.com",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
if len(test.exp) == 1 {
|
if len(test.exp) == 1 {
|
||||||
|
Loading…
Reference in New Issue
Block a user