Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

james2001
Copy link

use filter_var again Regex #1

Copy link

@xiaohuilam xiaohuilam left a 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)) {

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);

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);

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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants