Skip to content

fix hostname accepting values longer than 253 chars when they contain dots#444

Open
karthiksai109 wants to merge 1 commit intopython-validators:masterfrom
karthiksai109:fix/hostname-max-length-253
Open

fix hostname accepting values longer than 253 chars when they contain dots#444
karthiksai109 wants to merge 1 commit intopython-validators:masterfrom
karthiksai109:fix/hostname-max-length-253

Conversation

@karthiksai109
Copy link

Fixes #413

The hostname validator was only checking individual label lengths via the simple hostname regex but had no overall length limit on the full value. Hostnames with dots where each label was under 63 chars but the total length exceeded 253 would incorrectly pass validation.

Added a 253 character length check on the host segment (both with and without a port suffix) per RFC 1123. Also added a test case using the exact example from the issue.

… dots

Fixes python-validators#413

The hostname validator was only checking individual label lengths via
regex but had no overall length limit. Hostnames with dots that had
each label under 63 chars but total length over 253 would slip through.

Added a 253 character check on the host segment both with and without
a port, per RFC 1123. Added a test case for this.
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.

validators.hostname lets long hostnames through if they contain periods

1 participant