diff --git a/parse_test.go b/parse_test.go index 0096e004d..20fe9a6ac 100644 --- a/parse_test.go +++ b/parse_test.go @@ -144,6 +144,38 @@ func TestTXTEscapeParsing(t *testing.T) { } } +func TestTXTEscapeJustParse(t *testing.T) { + test := [][]string{ + {`unquoted`, `unquoted`}, + {`"quoted"`, `quoted`}, + //{`inner"quote`, `inner"quote`}, // Parse error + //{`"quoted"quote"`, `quoted"quote`}, // Parse error + {`"innerescaped\"quote"`, `innerescaped"quote`}, + {`1back\slash`, `1back\slash`}, + {`2back\\slash`, `2back\\slash`}, + {`3back\\\slash`, `3back\\\slash`}, + {`4back\\\\slash`, `4back\\\\slash`}, + {`5back\\\\\slash`, `5back\\\\\slash`}, + {`"q1back\slash"`, `1backslash`}, + {`"q2back\\slash"`, `2back\slash`}, + {`"q3back\\\slash"`, `3back\slash`}, + {`"q4back\\\\slash"`, `4back\\slash`}, + {`"q5back\\\\\slash"`, `5back\\slash`}, + } + for _, s := range test { + rr, err := NewRR(fmt.Sprintf("example.com. IN TXT %v", s[0])) + if err != nil { + t.Errorf("could not parse %v TXT: %s", s[0], err) + continue + } + + parsed := rr.(*TXT).Txt[0] + if parsed != s[1] { + t.Errorf("mismatch after parsing `%v` TXT record: `%v` != `%v`", s[0], parsed, s[1]) + } + } +} + func GenerateDomain(r *rand.Rand, size int) []byte { dnLen := size % 70 // artificially limit size so there's less to interpret if a failure occurs var dn []byte