go-playground / validator

:100:Go Struct and Field validation, including Cross Field, Cross Struct, Map, Slice and Array diving
MIT License
16.83k stars 1.32k forks source link

validator "hostname" not properly working #1028

Open the-hotmann opened 1 year ago

the-hotmann commented 1 year ago

Package version eg. v9, v10:

v10.11.1

Issue, Question or Enhancement:

if you validate hostname against a hostname with a underscore _ in it's subdomain it will show it is invalid, while these hostnames are valid (uncommon, but valid).

Example: get_cert.hotmann.de does exist and work, but validator says no.

The domain is the very same in IDN, as in ACE (ASCII Compatible Encoding) - so it does not require some encoding to be displayed. Probably the validator just thinks domains with underscores _ in them are not valid - which they are.

nabbar commented 5 months ago

From the RFC 952, we can read : A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus sign (-), and period (.). Note that periods are only allowed when they serve to delimit components of "domain style names". (See RFC-921, "Domain Name System Implementation Schedule", for background). No blank or space characters are permitted as part of a name. No distinction is made between upper and lower case. The first character must be an alpha character. The last character must not be a minus sign or period.