-
Notifications
You must be signed in to change notification settings - Fork 334
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
🐛 Bug Report — Incorrect data returned from resolveTxt in node:dns
#3325
Comments
Thank you. I'll take a look at this. |
The current fix fixes multiple character strings, however completely breaks TXT records containing quotation marks. For example the following DNS record
Will be returned as [
[ 'testtesttest with quote' ]
] |
What should be the correct response in here? I'm not following. |
The correct response should contain the quotation mark, since it's part of the character string. For example in Node.js the response is [
[ 'testtesttest with " quote' ]
] For some context RFC 1035 specifies that a TXT record can contain one or more character strings, often they are split at the max lenght but a record with |
Noting that it does seem weird the response by Cloudflare doesn't correctly escape the " in the response, but taking how there's no real standard beyond "following Google's schema" can't say whether it's wrong. If it tries to follow the master files format then it would be incorrect.
Comparing it to other DNS servers, in the response of Quad9 it is correctly escpaped, and Google seems to omit the quotes. // Cloudflare DNS
{
"name": "theindra.nl",
"type": 16,
"TTL": 300,
"data": "\"test\"\"test\"\"test with \" quote\""
},
// Quad9
{
"name": "theindra.nl.",
"type": 16,
"TTL": 300,
"Expires": "Mon, 13 Jan 2025 20:06:19 UTC",
"data": "\"test\" \"test\" \"test with \\\" quote\""
},
// Google DNS
{
"name": "theindra.nl.",
"type": 16,
"TTL": 300,
"data": "testtesttest with \" quote"
}, |
Here's Node.js behavior
|
Seems like the behavior was changed between Node.js 20 and Node.js 22, both are correct however.
The current fix just seems very complex, likely due to the format returned by Cloudflare DNS not being very parseable since it fails to escape the quotes correctly. |
The current code in the
node:dns
implementation strips the leading and trailing quotation marks, however this results in an incorrect result for large TXT records with multiple quoted strings.workerd/src/node/internal/internal_dns_client.ts
Lines 235 to 242 in bdac140
As an example you can use resolve
s1024._domainkey.yahoo.com
, in Node.js this returnsBut in workerd this returns the following (note the quotation marks in the middle of the string)
The text was updated successfully, but these errors were encountered: