From d021dd20f15b86bd8b002fd87f5ef7b62e8f1e10 Mon Sep 17 00:00:00 2001 From: Bob Weinand Date: Thu, 7 Jul 2016 16:07:00 +0200 Subject: [PATCH] Fix broken hostname validation to match RFC 1123 2.1 Fixes #34 --- lib/DefaultResolver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/DefaultResolver.php b/lib/DefaultResolver.php index 699138e..044ef11 100644 --- a/lib/DefaultResolver.php +++ b/lib/DefaultResolver.php @@ -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' +/^(?[a-z0-9]([a-z0-9-]*[a-z0-9])?)(\.(?&name))*$/i +REGEX; return !isset($name[253]) && \preg_match($pattern, $name); }