Add special handling for the root zone on domain validation and IDNA conversion

Signed-off-by: Christian König <ckoenig@posteo.de>
This commit is contained in:
Christian König
2022-08-28 21:56:36 +02:00
parent 21521498b5
commit f4c264be86
2 changed files with 16 additions and 6 deletions

View File

@@ -12,6 +12,11 @@
ini_set('pcre.recursion_limit', 1500);
function validDomain($domain_name, &$message = null)
{
// special handling of the root zone `.`
if ($domain_name == '.') {
return true;
}
if (!preg_match('/^((-|_)*[a-z\\d]((-|_)*[a-z\\d])*(-|_)*)(\\.(-|_)*([a-z\\d]((-|_)*[a-z\\d])*))*$/i', $domain_name)) {
if ($message !== null) {
$message = 'it contains invalid characters';