Repository navigation
Look up the IDNA-encoded TLD when consider_tld is set - #523
Merged
nandgator merged 1 commit intoOct 22, 2026
Merged
Conversation
Collaborator
|
Thanks, this is the fix I'd like to merge for #522, and it's preferred over #524. Before it can go in, two things:
|
DevKaurav-14
force-pushed
the
fix/idn-tld-consider-tld
branch
from
October 22, 2026 02:12
867054a to
7b6ddc5
Compare
Contributor
Author
|
@nandgator I've rebased onto master and pushed.Could you approve the workflow runs? |
The IANA list stores internationalized TLDs in punycode (XN--P1AI), but domain() checked the raw Unicode TLD against it. Unicode domains such as пример.рф were rejected with consider_tld=True while their punycode form was accepted. hostname() and url() inherit this through domain(). Run the TLD check after IDNA encoding, on the encoded TLD.
nandgator
force-pushed
the
fix/idn-tld-consider-tld
branch
from
October 22, 2026 02:33
7b6ddc5 to
56a83b5
Compare
Collaborator
|
Thanks for rebasing, and sorry: the conflicts this time came from my own merges (#533 and #534 added tests in the same places right after your push). Since that was my doing, I rebased your commit onto master and pushed it to your branch. The conflicts were test-only, and I kept both sides. Your change and your authorship are unchanged. I approved the CI runs and merged once they were green. |
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.
Fixes #522
What was wrong
With
consider_tld=True,domain()looked up the raw TLD in the IANA list. The list stores IDN TLDs in punycode, so Unicode TLDs such as.рфor.中国were always rejected.hostname()andurl()inherited this throughdomain().Change
The TLD check now runs after IDNA encoding and uses the encoded TLD. Nothing else in the validation changes.
Tests
test_domain.py: Unicode TLDs (пример.рф,пример.рф.withrfc_1034,例子.中国) pass, and an unknown Unicode TLD (пример.рфы) fails.test_hostname.py,test_url.py: newconsider_tldcases for ASCII, punycode and Unicode TLDs, valid and invalid.The new tests fail without the fix.
ruff check,ruff format --checkandpyrightare clean.