mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-05-11 05:55:12 +00:00
TRANSIP: Fix TXT quoting (#2708)
Co-authored-by: Tom Limoncelli <tlimoncelli@stackoverflow.com>
This commit is contained in:
@@ -1126,7 +1126,8 @@ func makeTests(t *testing.T) []*TestGroup {
|
||||
tc("TXT with semicolon ws", txt("foosc2", `wssemi ; colon`)),
|
||||
|
||||
tc("TXT interior ws", txt("foosp", "with spaces")),
|
||||
tc("TXT trailing ws", txt("foows1", "with space at end ")),
|
||||
tc("TXT leading ws", txt("foowsb", " leadingspace")),
|
||||
tc("TXT trailing ws", txt("foows1", "trailingws ")),
|
||||
|
||||
// Vultr syntax-checks TXT records with SPF contents.
|
||||
tc("Create a TXT/SPF", txt("foo", "v=spf1 ip4:99.99.99.99 -all")),
|
||||
|
||||
@@ -17,6 +17,15 @@ func TxtHasBackslash(rc *models.RecordConfig) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// TxtStartsOrEndsWithSpaces audits TXT records that starts or ends with spaces
|
||||
func TxtStartsOrEndsWithSpaces(rc *models.RecordConfig) error {
|
||||
txt := rc.GetTargetTXTJoined()
|
||||
if len(txt) > 0 && (txt[0] == ' ' || txt[len(txt)-1] == ' ') {
|
||||
return fmt.Errorf("txtstring starts or ends with spaces")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// TxtHasBackticks audits TXT records for strings that contain backticks.
|
||||
func TxtHasBackticks(rc *models.RecordConfig) error {
|
||||
if strings.Contains(rc.GetTargetTXTJoined(), "`") {
|
||||
|
||||
@@ -19,5 +19,9 @@ func AuditRecords(records []*models.RecordConfig) []error {
|
||||
|
||||
a.Add("TXT", rejectif.TxtHasBackslash) // Last verified 2023-12-04
|
||||
|
||||
a.Add("TXT", rejectif.TxtStartsOrEndsWithSpaces) // Last verified 2023-12-10
|
||||
|
||||
a.Add("TXT", rejectif.TxtIsEmpty) // Last verified 2023-12-10
|
||||
|
||||
return a.Audit(records)
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v4/models"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/diff2"
|
||||
"github.com/StackExchange/dnscontrol/v4/pkg/txtutil"
|
||||
"github.com/StackExchange/dnscontrol/v4/providers"
|
||||
"github.com/transip/gotransip/v6"
|
||||
"github.com/transip/gotransip/v6/domain"
|
||||
@@ -310,7 +309,7 @@ func recordToNative(config *models.RecordConfig, useOriginal bool) (domain.DNSEn
|
||||
Name: config.Name,
|
||||
Expire: int(config.TTL),
|
||||
Type: config.Type,
|
||||
Content: config.GetTargetCombinedFunc(txtutil.EncodeQuoted),
|
||||
Content: config.GetTargetCombinedFunc(nil),
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -322,7 +321,7 @@ func nativeToRecord(entry domain.DNSEntry, origin string) (*models.RecordConfig,
|
||||
Original: entry,
|
||||
}
|
||||
rc.SetLabel(entry.Name, origin)
|
||||
if err := rc.PopulateFromStringFunc(entry.Type, entry.Content, origin, txtutil.ParseQuoted); err != nil {
|
||||
if err := rc.PopulateFromStringFunc(entry.Type, entry.Content, origin, nil); err != nil {
|
||||
return nil, fmt.Errorf("unparsable record received from TransIP: %w", err)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user