ZF-12362: Not working Zend_Validate_Hostname is Punycode Format URI

Description

testscript: validate-host.php ===========

<?php require_once 'Zend/Validate/Hostname.php';

$punycode_hostname = 'xn--wgv71a119e.jp';

// ======================================

$validator = new Zend_Validate_Hostname(array( 'allow' => Zend_Validate_Hostname::ALLOW_DNS, 'idn' => false, 'tld' => false, )); var_dump($validator->isValid($punycode_hostname)); var_dump($validator->getMessages());

die();

// ===================================

/* bool(false) / / array(1) { / / ["hostnameCannotDecodePunycode"]=> / / string(98) "'xn--wgv71a119e.jp' appears to be a DNS hostname but the given punycode notation cannot be decoded" / / } */

=========== testscript:validate-host.php

the point at issue: Zend/Validate/Hostname.php =================== Line: 596-601 if (strpos($domainPart, 'xn--') === 0) { $domainPart = $this->decodePunycode(substr($domainPart, 4)); if ($domainPart === false) { return false; } }

and

Line: 708-717 (in decodePunycode function) $separator = strrpos($encoded, '-'); if ($separator > 0) { for ($x = 0; $x < $separator; ++$x) { // prepare decoding matrix $decoded[] = ord($encoded[$x]); } } else { $this->_error(self::CANNOT_DECODE_PUNYCODE); return false; }

Comments

Seems it's duplicate of http://framework.zend.com/issues/browse/ZF-12035. Please vote it.