mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 12:24:38 +03:00
fix incorrect error about bare cr/lf when sending a message over smtp
we weren't properly tracking the cr's and lf's when being strict about message lines when sending data. we are reading buffered data from a Reader. if that chunk happens to start with a newline, we weren't looking at the previously written data, which could be a cr. instead, in that case, we would always claim the cr/lf wasn't correct. the new test case triggered the behaviour before having the fix. should solve issue #129 by x8x, thanks for the report!
This commit is contained in:
@ -40,8 +40,10 @@ func DataWrite(w io.Writer, r io.Reader) error {
|
||||
c := p[n]
|
||||
if c == '\n' {
|
||||
if firstcr < 0 {
|
||||
// Bare newline.
|
||||
return ErrCRLF
|
||||
if n > 0 || last != '\r' {
|
||||
// Bare newline.
|
||||
return ErrCRLF
|
||||
}
|
||||
} else if firstcr != n-1 {
|
||||
// Bare carriage return.
|
||||
return ErrCRLF
|
||||
|
Reference in New Issue
Block a user