-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Description
The DomainStr
type fails to accept valid punycode domain names with internationalized TLDs, such as:
xn--7-7sbirhro.xn--80ahmohdapg.xn--80asehdb
This domain is technically valid, but DomainStr
raises a validation error due to the regex pattern used:
_domain_re_pattern = r'(?=^.{1,253}$)(^((?!-)[a-zA-Z0-9-]{1,63}(?<!-)\.)+[a-zA-Z]{2,63}$)'
The final [a-zA-Z]{2,63}
segment disallows punycode TLDs like xn--p1ai
, xn--80asehdb
, etc., which are valid ASCII representations of internationalized domain names (IDNs).
Expected behavior
DomainStr
should allow punycode-based TLDs that conform to valid IDN formats (e.g., those starting with xn--
).
Suggested fix
Adjust the regex to support both regular TLDs and punycode (e.g. ([a-zA-Z]{2,63}|xn--[a-zA-Z0-9]{2,59})
).
Environment
- pydantic-extra-types version: 2.10.5
- Python version: 3.12
- Platform: (Linux/Windows/Mac)
Metadata
Metadata
Assignees
Labels
No labels