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
4 changes: 2 additions & 2 deletions protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
9 changes: 9 additions & 0 deletions protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ func TestParseMAIL(t *testing.T) {
m, err = proto.ParseMAIL("FROM:<oink>")
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")
Expand All @@ -550,6 +553,9 @@ func TestParseMAIL(t *testing.T) {
m, err = proto.ParseMAIL("FrOm:<oink@oink.mailhog.example>")
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: <oink>")
Expand All @@ -561,6 +567,9 @@ func TestParseMAIL(t *testing.T) {
m, err = proto.ParseMAIL("FrOm: <oink@oink.mailhog.example>")
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()
Expand Down