improve message parsing: allow bare carriage return (unless in pedantic mode), allow empty header, and no longer treat a message with only headers as a message with only a body

This commit is contained in:
Mechiel Lukkien
2023-08-11 14:07:49 +02:00
parent 79d06184ab
commit 48eb530b1f
10 changed files with 129 additions and 79 deletions

11
ctl.go
View File

@ -327,21 +327,16 @@ func servectlcmd(ctx context.Context, ctl *ctl, shutdown func()) {
log.Check(err, "closing temporary message file")
}
}()
mw := &message.Writer{Writer: msgFile}
mw := message.NewWriter(msgFile)
ctl.xwriteok()
ctl.xstreamto(mw)
err = msgFile.Sync()
ctl.xcheck(err, "syncing message to storage")
msgPrefix := []byte{}
if !mw.HaveHeaders {
msgPrefix = []byte("\r\n\r\n")
}
m := &store.Message{
Received: time.Now(),
Size: int64(len(msgPrefix)) + mw.Size,
MsgPrefix: msgPrefix,
Received: time.Now(),
Size: mw.Size,
}
a.WithWLock(func() {