-
Notifications
You must be signed in to change notification settings - Fork 136
Valid hostnames are consideres invalid with Umlaut and certain TLDs #234
Description
I initially encountered this problem while using the email
validator. However the real origin is the hostname
validator.
A simple testscript let's you reproduce this issue. In the example code I'm using an made up hostname, however the real one of my client is built up in the same manner: an german umlaut in the hostname as well as one of the newer tlds. Due to data privacy the script doesn't use the real hostname of my client.
The only thing you need to do is to install zend-validator via composer, create a script with the following code an run it within your browser:
<?php
require_once ('vendor/autoload.php');
// email validator tests
$validator = new \Zend\Validator\EmailAddress();
// this should return "success", but does not: umlaut & new tld
if (false === $validator->isValid('info@täst.tools')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success';
}
// new tld, but no umlaut -> works
if (false === $validator->isValid('[email protected]')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success<br>';
}
// umlaut but "classic" tld -> works
if (false === $validator->isValid('info@täst.com')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success<br>';
}
// hostname validator
$validator = new \Zend\Validator\Hostname();
// this should return "success", but does not: umlaut & new tld
if (false === $validator->isValid('täst.tools')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success<br>';
}
// new tld, but no umlaut -> works
if (false === $validator->isValid('test.tools')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success<br>';
}
// umlaut but "classic" tld -> works
if (false === $validator->isValid('täst.com')) {
echo'<pre>';print_r($validator->getMessages());echo'</pre>';
} else {
echo 'success<br>';
}
Basically the upper three test, test the email
validator, while the three later ones directly test the hostname
validator.
The output of the script looks like the following:
Array
(
[emailAddressInvalidHostname] => 'xn--tst-qla.tools' is not a valid hostname for the email address
[hostnameInvalidHostnameSchema] => The input appears to be a DNS hostname but cannot match against hostname schema for TLD 'TOOLS'
[hostnameLocalNameNotAllowed] => The input appears to be a local network name but local network names are not allowed
)
success
success
Array
(
[hostnameInvalidHostnameSchema] => The input appears to be a DNS hostname but cannot match against hostname schema for TLD 'TOOLS'
[hostnameInvalidLocalName] => The input does not appear to be a valid local network name
)
success
success
The first and fourth tests fail. And this is the issue. These are completely valid hostnames. Which are by the way not local.
Does anyone know how to fix this? I'm not deeply into the hostname
validator. Installed was version 2.10 of the validator
component.
For the background: we've developed a credential database application, with different types of credential-types and so on. One of the types is email credential
which respectively requires the email address. There we encountered this issue.