Skip to content

Commit

Permalink
fix: Handle multiple \rs in delimiter new line search
Browse files Browse the repository at this point in the history
  • Loading branch information
LBeernaertProton committed Oct 13, 2022
1 parent abec84b commit fc74679
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions rfc822/scanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ func indexOfNewLineAfterBoundary(data []byte) int {
return 0
}

if data[0] == '\n' {
return 0
} else if data[0] == '\r' && data[1] == '\n' {
return 1
//consume extra '\r's
index := 0
for ; index < dataLen && data[index] == '\r'; index++ {
}

if data[index] == '\n' {
return index
}

return -1
Expand Down

0 comments on commit fc74679

Please sign in to comment.