-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix DNS validation #3
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Submit my comment for a dns challenge case
@@ -88,26 +88,12 @@ protected function validateHostName(string $hostName): void | |||
|
|||
$hostnameErrorInfo = 'Invalid hostname ' . json_encode($hostName); | |||
|
|||
if (strlen($hostName) < 3) { | |||
if (!filter_var($hostName, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove , FILTER_FLAG_HOSTNAME
(keep
if (!filter_var($hostName, FILTER_VALIDATE_DOMAIN)) {
in this line).
because it will returns false:
$hostName = '_dnsauth.test.com';
var_dump(filter_var($hostName, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME));
@@ -13,7 +13,7 @@ public static function isValidDomainOrSubdomain(string $domain): bool | |||
if (empty($domain) || strlen($domain) < 4) { | |||
return false; | |||
} | |||
return preg_match(Regex::DOMAIN_OR_SUBDOMAIN, $domain) === 1; | |||
return (bool) filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (bool) filter_var($domain, FILTER_VALIDATE_DOMAIN);
@@ -103,7 +103,7 @@ public function isParentHostName($host): bool | |||
*/ | |||
private function isDomainOrSubdomainHostName(string $host): bool | |||
{ | |||
return preg_match(Regex::DOMAIN_OR_SUBDOMAIN, $host) === 1; | |||
return (bool) filter_var($host, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return (bool) filter_var($host, FILTER_VALIDATE_DOMAIN);
use filter_var again Regex #1