-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
server: Add a test to verify that <LF>.<LF> is not recognized as a me…
…ssage end
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -481,6 +481,50 @@ func TestServer(t *testing.T) { | |
} | ||
} | ||
|
||
func TestServer_LFDotLF(t *testing.T) { | ||
be, s, c, scanner := testServerAuthenticated(t) | ||
defer s.Close() | ||
defer c.Close() | ||
|
||
io.WriteString(c, "MAIL FROM:<[email protected]>\r\n") | ||
scanner.Scan() | ||
if !strings.HasPrefix(scanner.Text(), "250 ") { | ||
t.Fatal("Invalid MAIL response:", scanner.Text()) | ||
} | ||
|
||
io.WriteString(c, "RCPT TO:<[email protected]>\r\n") | ||
scanner.Scan() | ||
if !strings.HasPrefix(scanner.Text(), "250 ") { | ||
t.Fatal("Invalid RCPT response:", scanner.Text()) | ||
} | ||
|
||
io.WriteString(c, "DATA\r\n") | ||
scanner.Scan() | ||
if !strings.HasPrefix(scanner.Text(), "354 ") { | ||
t.Fatal("Invalid DATA response:", scanner.Text()) | ||
} | ||
|
||
io.WriteString(c, "From: [email protected]\r\n") | ||
io.WriteString(c, "\r\n") | ||
io.WriteString(c, "hey\r\n") | ||
io.WriteString(c, "\n.\n") | ||
io.WriteString(c, "this is going to break your server\r\n") | ||
io.WriteString(c, ".\r\n") | ||
scanner.Scan() | ||
if !strings.HasPrefix(scanner.Text(), "250 ") { | ||
t.Fatal("Invalid DATA response:", scanner.Text()) | ||
} | ||
|
||
if len(be.messages) != 1 || len(be.anonmsgs) != 0 { | ||
t.Fatal("Invalid number of sent messages:", be.messages, be.anonmsgs) | ||
} | ||
|
||
msg := be.messages[0] | ||
if string(msg.Data) != "From: [email protected]\r\n\r\nhey\r\n\n.\nthis is going to break your server\r\n" { | ||
t.Fatal("Invalid mail data:", string(msg.Data)) | ||
} | ||
} | ||
|
||
func TestServer_authDisabled(t *testing.T) { | ||
_, s, c, scanner, caps := testServerEhlo(t, authDisabled) | ||
defer s.Close() | ||
|