From e29f7440f5c2ff8e64a33e8ed2486b68b24050c3 Mon Sep 17 00:00:00 2001 From: Sven Peter Date: Sat, 28 Nov 2020 21:38:58 +0100 Subject: [PATCH] INWX: Guard against single-quote TXT targets (#971) * INWX: split out and disable TXT with single-quote test * INWX: add check for single-quotes in TXT records --- integrationTest/integration_test.go | 5 ++++- providers/inwx/inwxProvider.go | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 1be315426..03b3e9c42 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -683,7 +683,10 @@ func makeTests(t *testing.T) []*TestGroup { tc("Create 1 TXT as array", txtmulti("foo", []string{"simple"})), // Same as non-TXTMulti clear(), tc("Create a 255-byte TXT", txt("foo", strings.Repeat("A", 255))), - clear(), + ), + + testgroup("single TXT with single-quote", + not("INWX"), tc("Create TXT with single-quote", txt("foo", "blah`blah")), ), diff --git a/providers/inwx/inwxProvider.go b/providers/inwx/inwxProvider.go index c1c221e32..b837892a3 100644 --- a/providers/inwx/inwxProvider.go +++ b/providers/inwx/inwxProvider.go @@ -207,6 +207,18 @@ func (api *inwxAPI) deleteRecord(RecordID int) error { return api.client.Nameservers.DeleteRecord(RecordID) } +// checkRecords ensures that there is no single-quote inside TXT records which would be ignored by INWX. +func checkRecords(records models.Records) error { + for _, r := range records { + if r.Type == "TXT" { + if strings.ContainsAny(r.Target, "`") { + return fmt.Errorf("INWX TXT records do not support single-quotes in their target") + } + } + } + return nil +} + // GetDomainCorrections finds the currently existing records and returns the corrections required to update them. func (api *inwxAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Correction, error) { dc.Punycode() @@ -218,6 +230,11 @@ func (api *inwxAPI) GetDomainCorrections(dc *models.DomainConfig) ([]*models.Cor models.PostProcessRecords(foundRecords) + err = checkRecords(dc.Records) + if err != nil { + return nil, err + } + differ := diff.New(dc) _, create, del, mod, err := differ.IncrementalDiff(foundRecords) if err != nil {