Skip to content

classify xn--90ae (бг) as a country-code TLD#409

Merged
sebbASF merged 1 commit into
apache:masterfrom
sahvx655-wq:bg-country-code-tld
Jun 23, 2026
Merged

classify xn--90ae (бг) as a country-code TLD#409
sebbASF merged 1 commit into
apache:masterfrom
sahvx655-wq:bg-country-code-tld

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

DomainValidator keeps the IANA TLD lists as sorted arrays and decides a TLD's category from which array holds it. While going over the IDN country-code entries I noticed бг (punycode xn--90ae) sitting in GENERIC_TLDS, even though its Cyrillic neighbours срб and бел are in COUNTRY_CODE_TLDS. бг is the ccTLD delegated to Bulgaria for the two-letter code BG, so isValidCountryCodeTld("xn--90ae") and isValidCountryCodeTld("бг") wrongly return false while isValidGenericTld("xn--90ae") returns true.

Moving the entry into COUNTRY_CODE_TLDS, in its sorted position so the binary-search lookup still holds, makes the per-category checks agree with the IANA delegation. isValidTld and isValid already returned true through the category OR, so only the category-specific methods change behaviour. Left as is, callers that branch on TLD category (treating ccTLDs differently from gTLDs) mishandle Bulgarian domains. Added the matching assertions to DomainValidatorTest.testTopLevelDomains.

@sebbASF

sebbASF commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

The lists are derived automatically from
https://data.iana.org/TLD/tlds-alpha-by-domain.txt
and
https://www.iana.org/domains/root/db

It looks like xn--90ae is somehow not being classified correctly.

Any fixes to the table need to be done by correcting the logic, otherwise they may be reverted when the lists are next regenerated.

I'll have a look and see if I can find the problem.
Meanwhile, marking as draft because the PR is incomplete.

@sebbASF sebbASF marked this pull request as draft June 23, 2026 12:43
@sebbASF

sebbASF commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Found the issue - the test did not check if the TLD was in the correct list.
If a TLD was originally added to the GENERIC list, changes were not detected.

@sebbASF sebbASF marked this pull request as ready for review June 23, 2026 14:35
@sebbASF sebbASF merged commit 1bbf0da into apache:master Jun 23, 2026
10 checks passed
@sebbASF

sebbASF commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants