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

BUGFIX: CAA records may include quoted spaces #1374 (#1377)

This commit is contained in:
Tom Limoncelli
2022-01-25 09:57:20 -05:00
committed by GitHub
parent 263c6b7290
commit b73d37908c
4 changed files with 49 additions and 4 deletions

View File

@@ -71,9 +71,33 @@ func TestSetTxtParse(t *testing.T) {
t.Errorf("%v: expected TxtStrings=(%v) got (%v)", i, test.e2, ls)
}
for i := range ls {
if len(ls[i]) != len(test.e2[i]) {
if ls[i] != test.e2[i] {
t.Errorf("%v: expected TxtStrings=(%v) got (%v)", i, test.e2, ls)
}
}
}
}
func TestParseQuotedFields(t *testing.T) {
tests := []struct {
d1 string
e1 []string
}{
{`1 2 3`, []string{`1`, `2`, `3`}},
{`1 "2" 3`, []string{`1`, `2`, `3`}},
{`1 2 "three 3"`, []string{`1`, `2`, `three 3`}},
{`0 issue "letsencrypt.org; validationmethods=dns-01; accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/1234"`, []string{`0`, `issue`, `letsencrypt.org; validationmethods=dns-01; accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/1234`}},
}
for i, test := range tests {
ls, _ := ParseQuotedFields(test.d1)
//fmt.Printf("%v: expected TxtStrings:\nWANT: %v\n GOT: %v\n", i, test.e1, ls)
if len(ls) != len(test.e1) {
t.Errorf("%v: expected TxtStrings=(%v) got (%v)", i, test.e1, ls)
}
for i := range ls {
if ls[i] != test.e1[i] {
t.Errorf("%v: expected TxtStrings=(%v) got (%v)", i, test.e1, ls)
}
}
}
}