-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parsing TXT records does not properly de-escape quotes #1384
Comments
[ Quoting ***@***.***> in "[miekg/dns] Parsing TXT records doe..." ]
When calling NewRR() on a TXT record, an escaped quote isn't properly
de-escaped.
A line such as:
example.com. IN TXT "inner\"quote"
It gets parsed to: inner\"quote
I was expecting: inner"quote
but if you put that back in the NewRR you lost the fact that it was quoted...
We've have multiple discussions about this throughout the years, mostly because the
original RFC text sucks - I think the current behavior is correct
|
"you lost the fact that it was quoted" -- I would imagine that the fact that it is ASCII 34 means it was quoted. Can the string be formed any other way? |
trouble parsing what you mean here. I still believe current behavior is correct, as calling this should give the same output: NewRR -> String() -> NewRR on that string -> String() etc. |
Sorry for being unclear. Question: Should newRR() simply remove the outer quotes (if they exist) or should it de-escape interior double-quotes too? I expected it to do the latter. I wrote a It looks like NewRR() doesn't de-escape interior quotes. (i.e. replace
When we round-trip the strings by calling If you look at https://github.com/miekg/dns/pull/1383/files, you'll see the a 2 tests, one should fail and the other should pass.
If no de-escaping is intended, then there's no bug. Tom |
We've just run into a related issue. In this comment,
The (For simplicity, all strings in this comment are raw/literal strings, without Go syntax. In other words, every backslash above is a literal backslash and every quote is a literal quote, such as a quote in a zone file.) Edit: I've opened #1540 to fix the immediate issue, though I still think it'd be smart not to store escape sequences in parsed data structures (just like JSON escape sequences in strings aren't preserved when using Unmarshal, etc.), even though that's technically a breaking change. |
When calling NewRR() on a TXT record, an escaped quote isn't properly de-escaped.
A line such as:
It gets parsed to:
inner\"quote
I was expecting:
inner"quote
Maybe I'm misreading the RFC? It just seems that without removing the
\
there's no way to know what the\
means in the resulting string.I've created #1383 to demonstrate the issue.
The text was updated successfully, but these errors were encountered: