diff --git a/pkg/server/smtp/handler.go b/pkg/server/smtp/handler.go index f9e9a55..baa8722 100644 --- a/pkg/server/smtp/handler.go +++ b/pkg/server/smtp/handler.go @@ -58,7 +58,7 @@ const ( // as quoted pair and in double quoted strings (?i) makes the regex case insensitive, (?:) is // non-grouping sub-match. Accepts empty angle bracket value in options for 'AUTH=<>'. var fromRegex = regexp.MustCompile( - `(?i)^FROM:\s*<((?:(?:\\>|[^>])+|"[^"]+"@[^>])+)?>( [\w= ]+(?:=<>)?)?$`) + `(?i)^FROM:\s*<((?:(?:\\>|[^>])+|"[^"]+"@[^>])+)?>( ([\w= ]|=<>)+)?$`) func (s State) String() string { switch s { @@ -619,7 +619,7 @@ func (s *Session) parseCmd(line string) (cmd string, arg string, ok bool) { // The leading space is mandatory. func (s *Session) parseArgs(arg string) (args map[string]string, ok bool) { args = make(map[string]string) - re := regexp.MustCompile(` (\w+)=(\w+)`) + re := regexp.MustCompile(` (\w+)=(\w+|<>)`) pm := re.FindAllStringSubmatch(arg, -1) if pm == nil { s.logger.Warn().Msgf("Failed to parse arg string: %q", arg) diff --git a/pkg/server/smtp/handler_test.go b/pkg/server/smtp/handler_test.go index 582dc42..2d77bfe 100644 --- a/pkg/server/smtp/handler_test.go +++ b/pkg/server/smtp/handler_test.go @@ -197,6 +197,8 @@ func TestReadyState(t *testing.T) { {"RSET", 250}, {"MAIL FROM: SIZE=4096 AUTH=<>", 250}, {"RSET", 250}, + {"MAIL FROM: SIZE=4096 AUTH=<> BODY=7BIT", 250}, + {"RSET", 250}, {"MAIL FROM:", 250}, {"RSET", 250}, {"MAIL FROM:<\"first last\"@space.com>", 250}, diff --git a/shell.nix b/shell.nix index b73e4f1..f95956f 100644 --- a/shell.nix +++ b/shell.nix @@ -11,7 +11,7 @@ stdenv.mkDerivation rec { elmPackages.elm-json elmPackages.elm-language-server elmPackages.elm-test - go + go_1_18 golint nodejs-16_x nodePackages.yarn