pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/python-validators/validators/pull/445/files

ithub.githubassets.com/assets/primer-primitives-10bf9dd67e3d70bd.css" /> fix: reject hostnames exceeding 253 characters by Jo2234 · Pull Request #445 · python-validators/validators · GitHub
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/validators/hostname.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ def hostname(
if not value:
return False

# Determine the host part (strip port if present) for length validation
host_part = value
if may_have_port:
if (seg := _port_validator(value)):
host_part = seg

# Strip IPv6 brackets for length check
host_part = host_part.lstrip("[").rstrip("]")

# RFC 1123: total hostname length must not exceed 253 characters
# (excluding optional trailing dot)
if len(host_part.rstrip(".")) > 253:
return False

if may_have_port and (host_seg := _port_validator(value)):
return (
(_simple_hostname_regex().match(host_seg) if maybe_simple else False)
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy