diff --git a/docs/_includes/matrix.html b/docs/_includes/matrix.html index 984239443..2faef5f22 100644 --- a/docs/_includes/matrix.html +++ b/docs/_includes/matrix.html @@ -365,7 +365,9 @@ - + + + diff --git a/integrationTest/integration_test.go b/integrationTest/integration_test.go index 41cde4103..a470f9162 100644 --- a/integrationTest/integration_test.go +++ b/integrationTest/integration_test.go @@ -466,11 +466,17 @@ func makeTests(t *testing.T) []*TestCase { txtmulti("foo2", []string{"one", "two"}), txtmulti("foo3", []string{"eh", "bee", "cee"}), ), + tc("Create TXTMulti with quotes", + txtmulti("foo1", []string{"simple"}), + txtmulti("foo2", []string{"o\"ne", "tw\"o"}), + txtmulti("foo3", []string{"eh", "bee", "cee"}), + ), tc("Change TXTMulti", txtmulti("foo1", []string{"dimple"}), txtmulti("foo2", []string{"fun", "two"}), txtmulti("foo3", []string{"eh", "bzz", "cee"}), ), + tc("Empty"), ) } diff --git a/providers/namedotcom/namedotcomProvider.go b/providers/namedotcom/namedotcomProvider.go index e593f32c1..818e35a04 100644 --- a/providers/namedotcom/namedotcomProvider.go +++ b/providers/namedotcom/namedotcomProvider.go @@ -22,6 +22,7 @@ var features = providers.DocumentationNotes{ providers.CanUseAlias: providers.Can(), providers.CanUsePTR: providers.Cannot("PTR records are not supported (See Link)", "https://www.name.com/support/articles/205188508-Reverse-DNS-records"), providers.CanUseSRV: providers.Can(), + providers.CanUseTXTMulti: providers.Can(), providers.DocCreateDomains: providers.Cannot("New domains require registration"), providers.DocDualHost: providers.Cannot("Apex NS records not editable"), providers.DocOfficiallySupported: providers.Can(), diff --git a/providers/namedotcom/records.go b/providers/namedotcom/records.go index 37223ad47..30569b524 100644 --- a/providers/namedotcom/records.go +++ b/providers/namedotcom/records.go @@ -2,6 +2,7 @@ package namedotcom import ( "fmt" + "regexp" "strconv" "strings" @@ -82,6 +83,9 @@ func checkNSModifications(dc *models.DomainConfig) { dc.Records = newList } +// finds a string surrounded by quotes that might contain an escaped quote charactor. +var quotedStringRegexp = regexp.MustCompile("\"((?:[^\"\\\\]|\\\\.)*)\"") + func toRecord(r *namecom.Record) *models.RecordConfig { rc := &models.RecordConfig{ NameFQDN: r.Fqdn, @@ -91,8 +95,16 @@ func toRecord(r *namecom.Record) *models.RecordConfig { Original: r, } switch r.Type { // #rtype_variations - case "A", "AAAA", "ANAME", "CNAME", "NS", "TXT": + case "A", "AAAA", "ANAME", "CNAME", "NS": // nothing additional. + case "TXT": + if r.Answer[0] == '"' && r.Answer[len(r.Answer)-1] == '"' { + txtStrings := []string{} + for _, t := range quotedStringRegexp.FindAllStringSubmatch(r.Answer, -1) { + txtStrings = append(txtStrings, t[1]) + } + rc.SetTxts(txtStrings) + } case "MX": rc.MxPreference = uint16(r.Priority) case "SRV": @@ -153,8 +165,15 @@ func (n *NameCom) createRecord(rc *models.RecordConfig, domain string) error { } switch rc.Type { // #rtype_variations - case "A", "AAAA", "ANAME", "CNAME", "MX", "NS", "TXT": + case "A", "AAAA", "ANAME", "CNAME", "MX", "NS": // nothing + case "TXT": + if len(rc.TxtStrings) > 1 { + record.Answer = "" + for _, t := range rc.TxtStrings { + record.Answer += "\"" + strings.Replace(t, "\"", "\\\"", -1) + "\"" + } + } case "SRV": record.Answer = fmt.Sprintf("%d %d %v", rc.SrvWeight, rc.SrvPort, rc.Target) record.Priority = uint32(rc.SrvPriority)