ZF-9671: Hostname validation is too strict about underscores

Issue Type: Bug Created: 2010-04-13T08:19:40.000+0000 Last Updated: 2011-07-31T21:20:44.000+0000 Status: Resolved Fix version(s): - 1.10.4 (28/Apr/10)

Reporter: Doron Gutman (gshockoman) Assignee: Thomas Weidner (thomas) Tags: - Zend_Http_Client

  • Zend_Validate

Related issues: Attachments:


According to…, "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

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


Posted by Thomas Weidner (thomas) on 2010-04-15T14:27:51.000+0000

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.<> specifies a service pointer for an SCTP capable webserver host (www) in the domain

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.

Posted by Phil Brown (philbrown) on 2011-03-15T15:57:07.000+0000

Please read this answer on StackOverflow -…

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

Posted by Thomas Weidner (thomas) on 2011-03-25T18:35:59.000+0000

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.

Posted by Thomas Weidner (thomas) on 2011-07-31T21:20:44.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.