peroxide: Make message header unfolding RFC822 compliant

create-reload-action
Lukasz Janyst 4 years ago
parent 4a2a9e5cd8
commit 0599dca910
No known key found for this signature in database
GPG Key ID: 32DE641041F17A9A
  1. 7
      pkg/message/header.go

@ -32,13 +32,12 @@ import (
func HeaderLines(header []byte) [][]byte {
var (
lines [][]byte
quote int
)
forEachLine(bufio.NewReader(bytes.NewReader(header)), func(line []byte) {
l := bytes.SplitN(line, []byte(`: `), 2)
isLineContinuation := quote%2 != 0 || // no quotes opened
!bytes.Equal(bytes.TrimLeftFunc(l[0], unicode.IsSpace), l[0]) // has whitespace indent at beginning
isLineContinuation := !bytes.Equal(bytes.TrimLeftFunc(l[0], unicode.IsSpace), l[0]) // has whitespace indent at beginning
switch {
case len(bytes.TrimSpace(line)) == 0:
lines = append(lines, line)
@ -53,8 +52,6 @@ func HeaderLines(header []byte) [][]byte {
default:
lines = append(lines, line)
}
quote += bytes.Count(line, []byte(`"`))
})
return lines

Loading…
Cancel
Save