Skip to content

Commit

Permalink
format long multi-string dkim txt records for rsa 2048 as a mult-line…
Browse files Browse the repository at this point in the history
… record, enclosed in ()'s

more easily readable, though still long
  • Loading branch information
mjl- committed Oct 13, 2023
1 parent 4004054 commit 14d09bb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions mox-/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,14 @@ import (
)

// TXTStrings returns a TXT record value as one or more quoted strings, taking the max
// length of 255 characters for a string into account.
// length of 255 characters for a string into account. In case of multiple
// strings, a multi-line record is returned.
func TXTStrings(s string) string {
r := ""
if len(s) <= 255 {
return `"` + s + `"`
}

r := "(\n"
for len(s) > 0 {
n := len(s)
if n > 255 {
Expand All @@ -46,9 +51,10 @@ func TXTStrings(s string) string {
if r != "" {
r += " "
}
r += `"` + s[:n] + `"`
r += "\t\t\"" + s[:n] + "\"\n"
s = s[n:]
}
r += "\t)"
return r
}

Expand Down

0 comments on commit 14d09bb

Please sign in to comment.