2022-07-15 02:43:07 +08:00
|
|
|
# TXT record testing
|
|
|
|
|
2023-08-24 22:31:04 +08:00
|
|
|
We recently discovered a strange bug with processing TXT records and
|
2023-03-13 01:22:56 +08:00
|
|
|
double-quotes. Sadly we haven't been able to determine a way to test this
|
|
|
|
automatically. Therefore, I've written up this methodology.
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
# The problem
|
|
|
|
|
|
|
|
The problem relates to TXT records that have a string with quotes in them.
|
|
|
|
|
2023-03-13 01:22:56 +08:00
|
|
|
If a user creates a TXT record whose contents are `"something"` (yes, with
|
2022-07-15 02:43:07 +08:00
|
|
|
double quotes), some APIs get confused.
|
|
|
|
|
|
|
|
This bug is most likely to appear in a provider that uses
|
|
|
|
`RecordConfig.PopulateFromString()` (see `models/t_parse.go`) to create TXT
|
|
|
|
records. That function assumes the string should always have the quotes
|
|
|
|
stripped, though it is more likely that the string should be taken verbatim.
|
|
|
|
|
|
|
|
# The test
|
|
|
|
|
|
|
|
To complete this test, you will need a test domain that you can add records to.
|
|
|
|
It won't be modified otherwise.
|
|
|
|
|
|
|
|
This bug has to do with double-quotes at the start and end of TXT records. If
|
|
|
|
your provider doesn't permit double-quotes in TXT records (you'd be surprised!)
|
|
|
|
you don't have to worry about this bug because those records are banned
|
|
|
|
in your `auditrecords.go` file.
|
|
|
|
|
2023-01-20 20:56:20 +08:00
|
|
|
## Step 1: Create the test records
|
2022-07-15 02:43:07 +08:00
|
|
|
|
2023-03-13 01:22:56 +08:00
|
|
|
Log into your DNS provider's web UI (portal) and create these 4 TXT records. (Don't use DNSControl!) Yes, include the double-quotes on test 2 and 3!
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
| Hostname | TXT |
|
|
|
|
|---------------|-----------|
|
|
|
|
| t0 | test0 |
|
|
|
|
| t1 | test1 |
|
|
|
|
| t2 | "test2" |
|
|
|
|
| t3 | "test3" |
|
|
|
|
|
|
|
|
|
2023-01-20 20:56:20 +08:00
|
|
|
## Step 2: Update `dnsconfig.js`
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
Now in your `dnsconfig.js` file, add these records to the domain:
|
|
|
|
|
|
|
|
TXT("t0", "test0"),
|
|
|
|
TXT("t1", "\"test1\""),
|
|
|
|
TXT("t2", "test2"),
|
|
|
|
TXT("t3", "\"test3\""),
|
|
|
|
|
2023-01-20 20:56:20 +08:00
|
|
|
## Step 3: Preview
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
When you do a `dnscontrol preview`, you should see changes for t1 and t2.
|
|
|
|
|
2022-11-01 06:09:43 +08:00
|
|
|
```text
|
2022-07-15 02:43:07 +08:00
|
|
|
#1: MODIFY TXT t1.example.com: ("test1" ttl=1) -> ("\"test1\"" ttl=1)
|
|
|
|
#2: MODIFY TXT t2.example.com: ("\"test2\"" ttl=1) -> ("test2" ttl=1)
|
|
|
|
```
|
|
|
|
|
|
|
|
If you don't see those changes, that's a bug. For example, we found that
|
2022-08-09 01:00:58 +08:00
|
|
|
Cloudflare left t2 alone but would try to add double-quotes to t3! This was
|
2023-01-20 20:56:20 +08:00
|
|
|
fixed in [PR#1543](https://github.com/StackExchange/dnscontrol/pull/1543).
|
2022-07-15 02:43:07 +08:00
|
|
|
|
2023-01-20 20:56:20 +08:00
|
|
|
## Step 4: Push
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
Let's assume you DO see the changes. Push them using `dnscontrol push`
|
|
|
|
then check the webui to see that the changes are correct.
|
|
|
|
|
2022-11-01 06:09:43 +08:00
|
|
|
```text
|
2022-07-15 02:43:07 +08:00
|
|
|
2 corrections
|
|
|
|
#1: MODIFY TXT t1.stackoverflow.help: ("test1" ttl=1) -> ("\"test1\"" ttl=1)
|
|
|
|
SUCCESS!
|
|
|
|
#2: MODIFY TXT t2.stackoverflow.help: ("\"test2\"" ttl=1) -> ("test2" ttl=1)
|
|
|
|
SUCCESS!
|
|
|
|
```
|
|
|
|
|
|
|
|
Refresh your provider's web UI and you should see the changes as expected: t1
|
|
|
|
should have double-quotes and t2 shouldn't. If the change wasn't correctly
|
|
|
|
done, that's a bug.
|
|
|
|
|
2023-01-20 20:56:20 +08:00
|
|
|
## Step 5: That's it!
|
2022-07-15 02:43:07 +08:00
|
|
|
|
|
|
|
Remove the lines from `dnsconfig.js` and run `dnscontrol push` to clean up.
|