1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-17 17:47:03 +00:00

SMTP handler is now more forgiving of line endings, a la Postfix

This commit is contained in:
James Hillyerd
2016-09-18 17:45:03 -07:00
parent a939605d4a
commit 1856deae46
2 changed files with 5 additions and 17 deletions

View File

@@ -23,7 +23,7 @@ const indexFileName = "index.gob"
var (
// indexLock is locked while reading/writing an index file
//
// NOTE: This is a bottleneck because it's a single lock even if we have a
// NOTE: This is a bottleneck because it's a single lock even if we have a
// million index files
indexLock = new(sync.RWMutex)

View File

@@ -393,7 +393,8 @@ func (ss *Session) dataHandler() {
return
}
line := lineBuf.Bytes()
if string(line) == ".\r\n" {
// ss.logTrace("DATA: %q", line)
if string(line) == ".\r\n" || string(line) == ".\n" {
// Mail data complete
if ss.server.storeMessages {
// Create a message for each valid recipient
@@ -492,28 +493,15 @@ func (ss *Session) readByteLine(buf *bytes.Buffer) error {
return err
}
for {
line, err := ss.reader.ReadBytes('\r')
line, err := ss.reader.ReadBytes('\n')
if err != nil {
return err
}
if _, err = buf.Write(line); err != nil {
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
}
// Else, keep looking
return nil
}
// Should be unreachable
}
// Reads a line of input