Added RFC 3403-compliant guard clauses to DnsNAPTRRecordData constructor#51
Open
zbalkan wants to merge 5 commits intoTechnitiumSoftware:masterfrom
Conversation
Signed-off-by: Zafer Balkan <zafer@zaferbalkan.com>
27c6b6f to
98a3ba5
Compare
This reverts commit 8bdc964.
There was a problem hiding this comment.
Pull request overview
This PR aims to enforce RFC 3403 structural constraints at construction time for DnsNAPTRRecordData, preventing creation of syntactically invalid NAPTR records (per issue #45).
Changes:
- Added null guard clauses for NAPTR
<character-string>fields (flags,services,regexp,replacement). - Added validation for RFC 3403 constraints (REGEXP/REPLACEMENT exclusivity, FLAGS character set, basic SERVICES sanity).
- Added a helper to validate
regexpvia .NETRegexcompilation (plus newSystem.Text.RegularExpressionsimport).
Comments suppressed due to low confidence (1)
TechnitiumLibrary.Net/Dns/ResourceRecords/DnsNAPTRRecordData.cs:123
IsDomainNameValid(replacement, true)is called even whenreplacementcontains a trailing dot; sinceIsDomainNameValidrejects empty labels, this will throw for any FQDN that ends with.. This further confirms the trailing-dot requirement above is incompatible with the validator. Normalizereplacement(e.g., trim a terminal dot) before validation, or remove the trailing-dot requirement entirely to match other RR constructors.
// DNS <character-string> constraints
if (DnsClient.IsDomainNameUnicode(replacement))
replacement = DnsClient.ConvertDomainNameToAscii(replacement);
DnsClient.IsDomainNameValid(replacement, true);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TechnitiumLibrary.Net/Dns/ResourceRecords/DnsNAPTRRecordData.cs
Outdated
Show resolved
Hide resolved
TechnitiumLibrary.Net/Dns/ResourceRecords/DnsNAPTRRecordData.cs
Outdated
Show resolved
Hide resolved
TechnitiumLibrary.Net/Dns/ResourceRecords/DnsNAPTRRecordData.cs
Outdated
Show resolved
Hide resolved
a531352 to
6dcaff3
Compare
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.
Solves #45
P.S: Renamed branch and reopened PR.