Issues

ZF-3570: Zend_Validate_Hostname - lengh check for idn domains incorrect

Description

Zend_Validate_Hostname does not validate the length of idn domains correctly.


$IDN = new Net_IDNA_php5();
$validator = new Zend_Validate_Hostname();
$host = "müslikjmnhjukiüöäüökiöäüökiijhnmjkiüöäimkjnhukääumhnjuikhum123n.de";
$hostascii = $IDN->encode($host);

echo "Domain: $host - length: ".(mb_strlen($host, "utf8")-3)." (without '.de')\n";
echo "Domain: $hostascii - length: ".(mb_strlen($hostascii, "utf8")-3)." (without '.de') \n";

if ($validator->isValid($host)) {
    echo "Hostname OK\n"; 
} else {
    foreach ($validator->getMessages() as $message) echo "$message\n";
}   

results in:

Domain: müslikjmnhjukiüöäüökiöäüökiijhnmjkiüöäimkjnhukääumhnjuikhum123n.de - length: 63 (without '.de'')
Domain: xn--mslikjmnhjukikikiijhnmjkiimkjnhukumhnjuikhum123n-n9dckia16gbacbk73amacfl.de - length: 76 (without '.de') 
Hostname OK

Hostname shouldn't be OK due to its length of 73 chars in Punycode.

Comments

New feature implemented with the last rework of Zend_Validate_Hostname