Skip to content

Reject an underscore in the last domain label - #485

Merged
nandgator merged 1 commit into
python-validators:masterfrom
SashaMIT:tld-underscore
Oct 10, 2026
Merged

nandgator merged 1 commit into
python-validators:masterfrom
SashaMIT:tld-underscore

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

domain("foo.ba_r") returned True, and domain("example.co_uk") did too. hostname("foo.ba_r") and email("a@foo.ba_r") did too.

An underscore is allowed in a service label when rfc_2782 is set. example_.com and _sip._tcp.example.com still need that flag, and they still pass with it. The last label allowed _ either way. example.com, xn----gtbspbbmkef.xn--p1ai, and a.co still pass.

Fixes #484.

Test plan

  • pytest tests/test_domain.py tests/test_hostname.py tests/test_email.py (119 passed)

The last label allowed "_" with or without rfc_2782, so foo.ba_r validated.
@nandgator
nandgator merged commit a3d77c8 into python-validators:master Oct 10, 2026
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Thanks for merging this. An underscore in the last label is no longer accepted as a domain.

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.

An underscore in the last domain label is accepted

2 participants