Repository navigation
Reject IDN labels that start or end with a hyphen - #593
Open
yuchengshen931122-creator wants to merge 1 commit into
Open
yuchengshen931122-creator wants to merge 1 commit into
yuchengshen931122-creator wants to merge 1 commit into
Conversation
domain() rejects "-bucher.de" and "bucher-.de", but accepted the same names
once the label holds a non-ASCII character:
domain("-bücher.de") # True
domain("bücher-.de") # True
The hyphen rule is applied to the encoded name, where such a label has become
"xn---bcher-4ya" and starts with "x". RFC 5891 (4.2.3.1) does not allow a
label to start or end with a hyphen, so the labels are now checked before
they are encoded.
Verdicts change only for labels that contain a non-ASCII character and have a
hyphen at either end (checked against master on 60,000 generated names);
hostname(), email() and url() follow through domain().
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This branch has not been deployed
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.
domain()rejects-bucher.deandbucher-.de, but accepts the same names once the label holds a non-ASCII character:domain("-bücher.de")anddomain("bücher-.de")are bothTrue. The hyphen rule is applied to the encoded name, where such a label has becomexn---bcher-4yaand starts withx.RFC 5891, section 4.2.3.1 does not allow a label to start or end with a hyphen. The labels are now checked before they are encoded.
hostname(),email()andurl()follow throughdomain().Verdicts change only for labels that contain a non-ASCII character and have a hyphen at either end: a comparison with master on 60,000 generated names (ASCII and non-ASCII, all flag combinations) shows no other difference. Hyphens inside a label and A-labels such as
xn--bcher-kva.destay valid.The added tests (19 cases) include 13 that fail on master. The full suite including doctests passes on Python 3.13 (1,593 passed); Ruff lint and format, Pyright and Bandit report nothing. Other Python versions are left to CI. The branch merges cleanly with every open pull request that touches
domain.py.Found while writing specification-based tests for a university software-testing course project (NYCU). Prepared with AI assistance; reproduced and tested locally.
🤖 Generated with Claude Code