Skip to content

Accept 62- and 63-character simple hostname labels - #544

Open
Zhuyuyangyy wants to merge 1 commit into
python-validators:masterfrom
Zhuyuyangyy:fix/simple-hostname-label-length
Open

Zhuyuyangyy wants to merge 1 commit into
python-validators:masterfrom
Zhuyuyangyy:fix/simple-hostname-label-length

Conversation

@Zhuyuyangyy

Copy link
Copy Markdown

Problem

hostname("a" * 62) and hostname("a" * 63) return ValidationError, although these are valid single-label hostnames. The rejection also affects ports, optional RFC 1034 trailing dots, and url(..., simple_host=True).

The regex reserves the first and last characters but only allows 59 characters between them, capping labels at 61. Multi-label hostnames already allow 63-character labels. RFC 1035 section 2.3.4 permits 63 octets per label; this regex only accepts ASCII.

Change

Allow up to 61 characters between the first and last label characters. Retain existing character restrictions, hyphen rules, and rejection above 63. Add 28 parameterized boundary cases covering hostnames, ports, optional trailing dots, and URLs with simple hosts enabled.

Validation

  • Before the implementation change: 12 new regression cases failed, 16 passed.
  • After the change: full test suite 1544 passed on Python 3.12.3.
  • Ruff lint and format checks pass for all three changed files.

This is a focused single-label boundary correction, not a change to domain-name or TLD policy.

AI assistance was used to identify the boundary case, implement the fix, and run the tests.

This branch has not been deployed

No deployments
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.

1 participant