From 0599dca9106b9123dbf137aa966dbbbe0910af0c Mon Sep 17 00:00:00 2001 From: Lukasz Janyst Date: Tue, 24 May 2022 12:15:38 +0200 Subject: [PATCH] peroxide: Make message header unfolding RFC822 compliant --- pkg/message/header.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pkg/message/header.go b/pkg/message/header.go index f28c429..ad66f2c 100644 --- a/pkg/message/header.go +++ b/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