1
0
mirror of https://github.com/danog/dns.git synced 2024-11-26 20:14:51 +01:00

Fix broken hostname validation to match RFC 1123 2.1

Fixes #34
This commit is contained in:
Bob Weinand 2016-07-07 16:07:00 +02:00
parent d9b2383624
commit d021dd20f1

View File

@ -84,7 +84,9 @@ class DefaultResolver implements Resolver {
}
private function isValidHostName($name) {
$pattern = "/^(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9]){0,1})(?:\\.[a-z0-9][a-z0-9-]{0,61}[a-z0-9])*$/i";
$pattern = <<<'REGEX'
/^(?<name>[a-z0-9]([a-z0-9-]*[a-z0-9])?)(\.(?&name))*$/i
REGEX;
return !isset($name[253]) && \preg_match($pattern, $name);
}