1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

NEW: rfc1035.go

This commit is contained in:
Tom Limoncelli
2023-10-27 15:34:10 -04:00
parent f0d0eb64ee
commit e97a48b90f

29
pkg/txtutil/rfc1035.go Normal file
View File

@@ -0,0 +1,29 @@
package txtutil
import (
"strings"
//"github.com/facebook/dns/dnsrocks/dnsdata/quote"
)
func RFC1035Quoted(s string) string {
s = strings.ReplaceAll(s, `\`, `\\`)
s = strings.ReplaceAll(s, `"`, `\"`)
return `"` + s + `"`
//sb := []byte(s) // The string, as []byte
//qb := quote.Bquote(sb) // Quote it.
//q := string(qb[:]) // Convert to string
//return `"` + q + `"`
}
func RFC1035ChunkedAndQuoted(s string) string {
parts := ToChunks(s)
var quotedParts []string
for _, part := range parts {
quotedParts = append(quotedParts, RFC1035Quoted(part))
}
return strings.Join(quotedParts, " ")
}