mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-29 16:15:04 +00:00
feat: check malformed domain names
This commit is contained in:
@@ -197,9 +197,18 @@ class RDAPService
|
||||
return $tldEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws MalformedDomainException
|
||||
*/
|
||||
public static function convertToIdn(string $fqdn): string
|
||||
{
|
||||
return strtolower(idn_to_ascii($fqdn));
|
||||
$ascii = strtolower(idn_to_ascii($fqdn));
|
||||
|
||||
if (OfficialDataService::DOMAIN_DOT !== $fqdn && !preg_match('/^(xn--)?[a-z0-9-]+(\.[a-z0-9-]+)*$/', $ascii)) {
|
||||
throw MalformedDomainException::fromDomain($fqdn);
|
||||
}
|
||||
|
||||
return $ascii;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user