Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/net/mail/message.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (p *addrParser) consumeAddrSpec() (spec string, err error) {

// domain = dot-atom / domain-literal
var domain string
p.skipSpace()

if p.empty() {
return "", errors.New("mail: no domain in addr-spec")
}
Expand Down
30 changes: 30 additions & 0 deletions src/net/mail/message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,36 @@ func TestAddressParsing(t *testing.T) {
Address: "jdoe@[192.168.0.1]",
}},
},
// No whitespace allowed in domain
{
`jdoe@machine.example`, // should pass
// `jdoe@ machine.example`, // should fail
[]*Address{{
Address: "jdoe@machine.example",
}},
},
{
`John Doe <jdoe@machine.example>`, // should pass
// `John Doe <jdoe@ machine.example>`, // should fail
[]*Address{{
Name: "John Doe",
Address: "jdoe@machine.example",
}},
},
{
` , joe@where.test,,John <jdoe@one.test>,,`, // should pass
// ` , joe@where.test,,John <jdoe@ one.test>,,`, // should fail
[]*Address{
{
Name: "",
Address: "joe@where.test",
},
{
Name: "John",
Address: "jdoe@one.test",
},
},
},
}
for _, test := range tests {
if len(test.exp) == 1 {
Expand Down