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:
29
pkg/txtutil/rfc1035.go
Normal file
29
pkg/txtutil/rfc1035.go
Normal 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, " ")
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user