mirror of
https://github.com/jhillyerd/inbucket.git
synced 2025-12-18 18:17:03 +00:00
SMTP handler is now more forgiving of line endings, a la Postfix
This commit is contained in:
@@ -393,7 +393,8 @@ func (ss *Session) dataHandler() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
line := lineBuf.Bytes()
|
line := lineBuf.Bytes()
|
||||||
if string(line) == ".\r\n" {
|
// ss.logTrace("DATA: %q", line)
|
||||||
|
if string(line) == ".\r\n" || string(line) == ".\n" {
|
||||||
// Mail data complete
|
// Mail data complete
|
||||||
if ss.server.storeMessages {
|
if ss.server.storeMessages {
|
||||||
// Create a message for each valid recipient
|
// Create a message for each valid recipient
|
||||||
@@ -492,28 +493,15 @@ func (ss *Session) readByteLine(buf *bytes.Buffer) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
line, err := ss.reader.ReadBytes('\r')
|
line, err := ss.reader.ReadBytes('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if _, err = buf.Write(line); err != nil {
|
if _, err = buf.Write(line); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
// Read the next byte looking for '\n'
|
|
||||||
c, err := ss.reader.ReadByte()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if err = buf.WriteByte(c); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if c == '\n' {
|
|
||||||
// We've reached the end of the line, return
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
// Else, keep looking
|
|
||||||
}
|
|
||||||
// Should be unreachable
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reads a line of input
|
// Reads a line of input
|
||||||
|
|||||||
Reference in New Issue
Block a user