Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support MAIL command with a null #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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:<[email protected]>")
So(err, ShouldBeNil)
So(m, ShouldEqual, "[email protected]")
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: <[email protected]>")
So(err, ShouldBeNil)
So(m, ShouldEqual, "[email protected]")
m, err = proto.ParseMAIL("FROM: <>")
So(err, ShouldBeNil)
So(m, ShouldEqual, "")
})
Convey("Error should be returned via Command", t, func() {
proto := NewProtocol()
Expand Down