maradns: decode CSV2 text without BIND parsing - #34
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
The parsing change is well-scoped and is backed by targeted new regression tests for the intended CSV2 decoding behavior.
Pull request overview
This PR fixes MaraDNS CSV2 TXT/SPF importing by decoding CSV2 text directly instead of running it through BIND-style parsing, preserving CSV2 quoting rules (notably quoted backslashes) and chunk boundaries.
Changes:
- Replace TXT/SPF handling in
maradns.parseZoneFileto build RR objects using a CSV2-specificparseText()decoder instead ofRR.fromBind(...). - Add regression tests covering quoted backslashes, hex/octal escapes, empty chunks, and malformed escapes.
- Update the MaraDNS fixture expectation so the tilde is emitted as a literal
~rather than\x7e.
File summaries
| File | Description |
|---|---|
lib/maradns.js |
Implements CSV2-specific TXT/SPF decoding (parseText) and bypasses BIND parsing for these RR types. |
test/csv2-text.js |
Adds focused regressions for CSV2 TXT/SPF decoding semantics and error cases. |
test/dns-zone.js |
Updates expected tinydns output to reflect correct decoding (tilde output). |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
220
to
+223
| case 'SPF': | ||
| case 'TXT': | ||
| iterRR.rdata = naturallyQuoted(iterRR.rdata) | ||
| if (!iterRR.rdata.startsWith('"')) iterRR.rdata = `"${iterRR.rdata}"` | ||
| break | ||
| res.push(new RR[iterRR.type]({ ...iterRR, data: parseText(iterRR.rdata) })) | ||
| continue |
Comment on lines
+431
to
+433
| const result = chunks.map((bytes) => | ||
| new TextDecoder('utf-8', { fatal: true }).decode(new Uint8Array(bytes)), | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CSV2 TXT/SPF import applied BIND escaping to a different format. Decode CSV2 text before constructing records, preserving quoted backslashes and string boundaries.
Add regressions for quoted text, hex and octal escapes, empty chunks and malformed escapes. The fixture now expects a tilde, not literal backslash-x7e.