ZF-2935: Zend_Uri_Http::validateHost should default to use Zend_Validate_Hostname::ALLOW_DNS and allow specification
Description
public function validateHost($host = null)
{
if ($host === null) {
$host = $this->_host;
}
/**
* If the host is empty, then it is considered invalid
*/
if (strlen($host) == 0) {
return false;
}
/**
* Check the host against the allowed values; delegated to Zend_Filter.
*/
$validate = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL);
return $validate->isValid($host);
}
I see two problems here:
1) Zend_Uri_Http::validateHost currently defaults to ALLOW_ALL when validating the hostname. This is inconsistent with other sections of code (Zend_Validate_EmailAddress, Zend_Validate_Hostname) which default to ALLOW_DNS (the expected behavior based on the documentation for Zend_Validate_Hostname).
2) There is currently no way to override this flag in the validateHost function.
Comments
Posted by Wil Sinclair (wil) on 2008-03-25T20:24:46.000+0000
Please categorize/fix as needed.
Posted by Thomas Weidner (thomas) on 2009-03-13T14:35:24.000+0000
Fixed component assignment
Posted by Adam Lundrigan (adamlundrigan) on 2011-12-02T02:25:15.000+0000
It is inconsistent, but is there any real-world use case where this becomes a handicap? We can easily rejig the component to allow setting the validator while maintaining BC, but doing so just because it's possible isn't the right reason.