Skip to content

Commit

Permalink
Check MAIL FROM AUTH parameter mailbox
Browse files Browse the repository at this point in the history
  • Loading branch information
emersion committed Aug 14, 2023
1 parent 0518064 commit 8b38375
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,14 @@ func (c *Conn) handleMail(arg string) {
}
if value == "<>" {
value = ""
} else {
p := parser{s: value}
value, err = p.parseMailbox()
if err != nil || p.s != "" {
c.writeResponse(500, EnhancedCode{5, 5, 4}, "Malformed AUTH parameter mailbox")
return
}
}
// TODO: otherwise, check mailbox syntax (RFC 2821 section 4.1.2)
opts.Auth = &value
default:
c.writeResponse(500, EnhancedCode{5, 5, 4}, "Unknown MAIL FROM argument")
Expand Down
4 changes: 2 additions & 2 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func TestParser(t *testing.T) {
{"<>", "", ""},
{"<[email protected]>", "[email protected]", ""},
{"[email protected]", "[email protected]", ""},
{"<[email protected]> AUTH=asdf", "[email protected]", " AUTH=asdf"},
{"[email protected] AUTH=asdf", "[email protected]", " AUTH=asdf"},
{"<[email protected]> AUTH=asdf@example.org", "[email protected]", " AUTH=asdf@example.org"},
{"[email protected] AUTH=asdf@example.org", "[email protected]", " AUTH=asdf@example.org"},
}
for _, tc := range validReversePaths {
p := parser{tc.raw}
Expand Down

0 comments on commit 8b38375

Please sign in to comment.