mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
when generating Authentication-Results, put each method on a new line for better readability
This commit is contained in:
parent
406fdc312d
commit
2710a5b971
3 changed files with 15 additions and 2 deletions
|
@ -66,6 +66,8 @@ func (h AuthResults) Header() string {
|
|||
w := &HeaderWriter{}
|
||||
w.Add("", "Authentication-Results:"+optComment(h.Comment)+" "+value(h.Hostname)+";")
|
||||
for i, m := range h.Methods {
|
||||
w.Newline()
|
||||
|
||||
tokens := []string{}
|
||||
addf := func(format string, args ...any) {
|
||||
s := fmt.Sprintf(format, args...)
|
||||
|
@ -86,10 +88,14 @@ func (h AuthResults) Header() string {
|
|||
addf("%s.%s=%s%s", p.Type, p.Property, v, optComment(p.Comment))
|
||||
}
|
||||
for j, t := range tokens {
|
||||
var sep string
|
||||
if j > 0 {
|
||||
sep = " "
|
||||
}
|
||||
if j == len(tokens)-1 && i < len(h.Methods)-1 {
|
||||
t += ";"
|
||||
}
|
||||
w.Add(" ", t)
|
||||
w.Add(sep, t)
|
||||
}
|
||||
}
|
||||
return w.String()
|
||||
|
|
|
@ -19,7 +19,7 @@ func TestAuthResults(t *testing.T) {
|
|||
},
|
||||
}
|
||||
s := authRes.Header()
|
||||
const exp = "Authentication-Results: (xn--mx-lka.example) møx.example; dkim=pass\r\n\theader.d=møx.example (xn--mx-lka.example)\r\n"
|
||||
const exp = "Authentication-Results: (xn--mx-lka.example) møx.example;\r\n\tdkim=pass header.d=møx.example (xn--mx-lka.example)\r\n"
|
||||
if s != exp {
|
||||
t.Fatalf("got %q, expected %q", s, exp)
|
||||
}
|
||||
|
|
|
@ -59,6 +59,13 @@ func (w *HeaderWriter) AddWrap(buf []byte) {
|
|||
}
|
||||
}
|
||||
|
||||
// Newline starts a new line.
|
||||
func (w *HeaderWriter) Newline() {
|
||||
w.b.WriteString("\r\n\t")
|
||||
w.lineLen = 1
|
||||
w.nonfirst = true
|
||||
}
|
||||
|
||||
// String returns the header in string form, ending with \r\n.
|
||||
func (w *HeaderWriter) String() string {
|
||||
return w.b.String() + "\r\n"
|
||||
|
|
Loading…
Reference in a new issue