Fix: Skip undecodable TXT records instead of raising exception during SPF lookup #232
+50
−6
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.
The library was rejecting domains with any TXT record containing invalid UTF-8, even when a valid SPF record existed. Per RFC 7208 § 4.5, only records beginning with
v=spf1should be processed—non-SPF records should be silently discarded.Changes
query_spf_record(): Check for undecodable characters after filtering for SPF records. Add warning and skip instead of raisingUndecodableCharactersInTXTRecord.get_spf_record(): Preserve and merge warnings fromquery_spf_record()with those fromparse_spf_record(). Previously warnings were being discarded.Example
If an actual SPF record (starting with
v=spf1) had undecodable characters, the behavior would be undefined since we cannot parse it—but this scenario is exceedingly rare and represents genuine DNS corruption rather than adjacent TXT records with different encodings.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
vmc.digicert.com/usr/bin/python python -m unittest discover -s . -p tests.py -v(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.