ZF-9671: Hostname validation is too strict about underscores

Description

According to http://en.wikipedia.org/wiki/Hostname/…, "While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore."

Zend_Validate_Hostname is not validating http://ex_ample.domain.com.

Please allow at least a way to make a lesser strict validation.

Comments

From the page you linked to:

{quote} The Internet standards (Request for Comments) for protocols mandate that component hostname labels may contain only the ASCII letters 'a' through 'z' (in a case-insensitive manner), the digits '0' through '9', and the hyphen (‐). The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen. However, a subsequent specification (RFC 1123) permitted hostname labels to start with digits. No other symbols, punctuation characters, or blank spaces are permitted.

While a hostname may not contain other characters, such as the underscore character (_), other DNS names may contain the underscore. Systems such as DomainKeys and service records use the underscore as a means to assure that their special character is not confused with hostnames. For example, _http._sctp.www.example.com specifies a service pointer for an SCTP capable webserver host (www) in the domain example.com.

A notable example of non-compliance with this specification, Microsoft Windows systems often use underscores in hostnames. Since some systems will reject invalid hostnames while others will not, the use of invalid hostname characters may cause subtle problems in systems that connect to standards-based services. For example, RFC-compliant mail servers will refuse to deliver mail for MS Windows computers with names containing underscores. {quote}

According to this entry, and also to the RFC a hostname is NOT allowed to include the "_" char.

Therefor Zend_Validate_Hostname, which is a validator for hostnames, should not allow to use this character as then it would accept invalid hostnames and return the as valid.

Feel free to use the regex validator for this purpose, or extend Zend_Validate_Hostname to accept invalid hostnames.

Please read this answer on StackOverflow - http://stackoverflow.com/questions/2180465/…

The problem here is that one cannot use a working URI containing underscores in the hostname in Zend_Http_Client

Please read the comment you attached carefully:

{quote} The original question was for domain names. If the question is for host names (or for URLs, which include a host name), then this is different, the relevant standard is RFC 1123, section 2.1 "Host Names and Numbers" which limits host names to letters-digits-hyphen. {quote}

This is exactly what I replied before.

Closing as non issue according to standards and replies as there was no further response