Skip to content

Commit

Permalink
Server: The value of BODY parameter is case-insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
ikedas authored and emersion committed Mar 23, 2024
1 parent b7d153a commit a3cdc26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,16 +355,18 @@ func (c *Conn) handleMail(arg string) {
}
opts.RequireTLS = true
case "BODY":
switch value {
case "BINARYMIME":
value = strings.ToUpper(value)
switch BodyType(value) {
case BodyBinaryMIME:
if !c.server.EnableBINARYMIME {
c.writeResponse(504, EnhancedCode{5, 5, 4}, "BINARYMIME is not implemented")
return
}
c.binarymime = true
case "7BIT", "8BITMIME":
case Body7Bit, Body8BitMIME:
// This space is intentionally left blank
default:
c.writeResponse(500, EnhancedCode{5, 5, 4}, "Unknown BODY value")
c.writeResponse(501, EnhancedCode{5, 5, 4}, "Unknown BODY value")
return
}
opts.Body = BodyType(value)
Expand Down
2 changes: 1 addition & 1 deletion server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ func TestServer8BITMIME(t *testing.T) {
defer s.Close()
defer c.Close()

io.WriteString(c, "MAIL FROM:<[email protected]> BODY=8BITMIME\r\n")
io.WriteString(c, "MAIL FROM:<[email protected]> BODY=8bitMIME\r\n")
scanner.Scan()
if !strings.HasPrefix(scanner.Text(), "250 ") {
t.Fatal("Invalid MAIL response:", scanner.Text())
Expand Down

0 comments on commit a3cdc26

Please sign in to comment.