You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
I have tried a isolated test of hostname.php by including 8 Files in order to resolve dependencies:
'ErrorHandler.php',
'StringWrapperInterface.php',
'AbstractStringWrapper.php',
'MbString.php',
'StringUtils.php',
'ArrayUtils.php',
'AbstractValidator.php',
'Hostname.php'
I have run about 15 test cases which was successful, except this one:
"123456789012345678901234567890123456789012345678901234567890123.de"
The domain name has regular chars [a-zA-z0-9] and allowed length of 63 chars.
$validator = new Hostname();
if ($validator->isValid($hostname)) {
// hostname appears to be valid
} else {
// hostname is invalid; print the reasons
foreach ($validator->getMessages() as $message) {
echo "$message\n";
}
}
I got:
PHP Fatal error: Call to a member function setTranslator() on a non-object in /Zend/Validator/Hostname.php on line 487
The line is strange but near of it 482 is setTranslator().
$this->setValue($value);
// Check input against IP address schema
if (preg_match('/^[0-9a-f:.]*$/i', $value) && $this->getIpValidator()
->setTranslator($this->getTranslator())
->isValid($value)) {
if (!($this->getAllow() & self::ALLOW_IP)) {
$this->error(self::IP_ADDRESS_NOT_ALLOWED);
return false;
} else {
return true;
}
}
IpValidator is not given. It is defined as optional in __construct.
And it is not an IP at all.
The text was updated successfully, but these errors were encountered:
In dependencies you have listed, you may have forgotten Ip.php.
When you instantiate Hostname without argument, the constructor set $options['ipValidator'], pass it to the parent constructor, call setOptions and setIpValidator() with null argument.
So $this->getIpValidator() returns a instance of Ip, and the error you have in line 487 must not be trigger.
I understand the Error and the dependency to Ip.php, and i have resolved these.
My point is only that:
IpValidator must be set, but according to the definition of __construct() is optional.
more important: checking of valid hostnames like "12345.de" does not work, because it is recognized falsely to be an IP (hexadecimals.:), but it is not.
there is no possibility to skip the IP-Check. Or is it? I see only ALLOW_IP.
not relevant to this thread: for domain '.name' there are no regex rules.
For 3) my solution was a pre-check for hexadecimal hostnames first and not calling Zend/Validator/Hostname.php for them at all. Is there better way to do this? Something like SKIP_IP_CHECK?
I have tried a isolated test of hostname.php by including 8 Files in order to resolve dependencies:
'ErrorHandler.php',
'StringWrapperInterface.php',
'AbstractStringWrapper.php',
'MbString.php',
'StringUtils.php',
'ArrayUtils.php',
'AbstractValidator.php',
'Hostname.php'
I have run about 15 test cases which was successful, except this one:
"123456789012345678901234567890123456789012345678901234567890123.de"
The domain name has regular chars [a-zA-z0-9] and allowed length of 63 chars.
The test is run with default basic usage according:
http://unofficial-zf2.readthedocs.org/en/latest/modules/zend.validator.hostname.html
$validator = new Hostname();
if ($validator->isValid($hostname)) {
// hostname appears to be valid
} else {
// hostname is invalid; print the reasons
foreach ($validator->getMessages() as $message) {
echo "$message\n";
}
}
I got:
PHP Fatal error: Call to a member function setTranslator() on a non-object in /Zend/Validator/Hostname.php on line 487
The line is strange but near of it 482 is setTranslator().
$this->setValue($value);
// Check input against IP address schema
if (preg_match('/^[0-9a-f:.]*$/i', $value) && $this->getIpValidator()
->setTranslator($this->getTranslator())
->isValid($value)) {
if (!($this->getAllow() & self::ALLOW_IP)) {
$this->error(self::IP_ADDRESS_NOT_ALLOWED);
return false;
} else {
return true;
}
}
IpValidator is not given. It is defined as optional in __construct.
And it is not an IP at all.
The text was updated successfully, but these errors were encountered: