diff --git a/protocol.go b/protocol.go index a09f82d..4c1a2f1 100644 --- a/protocol.go +++ b/protocol.go @@ -468,8 +468,8 @@ func (proto *Protocol) STARTTLS(args string) (reply *Reply) { return ReplyReadyToStartTLS(callback) } -var parseMailBrokenRegexp = regexp.MustCompile("(?i:From):\\s*<([^>]+)>") -var parseMailRFCRegexp = regexp.MustCompile("(?i:From):<([^>]+)>") +var parseMailBrokenRegexp = regexp.MustCompile("(?i:From):\\s*<([^>]*)>") +var parseMailRFCRegexp = regexp.MustCompile("(?i:From):<([^>]*)>") // ParseMAIL returns the forward-path from a MAIL command argument func (proto *Protocol) ParseMAIL(mail string) (string, error) { diff --git a/protocol_test.go b/protocol_test.go index 45f0125..de36dc0 100644 --- a/protocol_test.go +++ b/protocol_test.go @@ -533,6 +533,9 @@ func TestParseMAIL(t *testing.T) { m, err = proto.ParseMAIL("FROM:") So(err, ShouldBeNil) So(m, ShouldEqual, "oink") + m, err = proto.ParseMAIL("FROM:<>") + So(err, ShouldBeNil) + So(m, ShouldEqual, "") }) Convey("ParseMAIL should return an error for invalid syntax", t, func() { m, err := proto.ParseMAIL("FROM:oink") @@ -550,6 +553,9 @@ func TestParseMAIL(t *testing.T) { m, err = proto.ParseMAIL("FrOm:") So(err, ShouldBeNil) So(m, ShouldEqual, "oink@oink.mailhog.example") + m, err = proto.ParseMAIL("FrOm:<>") + So(err, ShouldBeNil) + So(m, ShouldEqual, "") }) Convey("ParseMAIL should support broken sender syntax", t, func() { m, err := proto.ParseMAIL("FROM: ") @@ -561,6 +567,9 @@ func TestParseMAIL(t *testing.T) { m, err = proto.ParseMAIL("FrOm: ") So(err, ShouldBeNil) So(m, ShouldEqual, "oink@oink.mailhog.example") + m, err = proto.ParseMAIL("FROM: <>") + So(err, ShouldBeNil) + So(m, ShouldEqual, "") }) Convey("Error should be returned via Command", t, func() { proto := NewProtocol()