bluelibraries / dns

PHP DNS info retriever
https://gethostinfo.com
GNU Lesser General Public License v2.1
7 stars 6 forks source link

When using IDN domain names, it is easy to reach the limit and throw exception Regex::DOMAIN_OR_SUBDOMAIN #1

Open xiaohuilam opened 1 year ago

xiaohuilam commented 1 year ago

https://github.com/bluelibraries/dns/blob/92208ec7fdeba26e0a1795904bc452fe92624e3a/src/Handlers/AbstractDnsHandler.php#L98-L103

bluelibraries commented 1 year ago

Thank you very much for notifying. Let's increase it to 255. What do you think?

bluelibraries commented 1 year ago

I'm on it.

xiaohuilam commented 1 year ago

Thank you very much for notifying. Let's increase it to 255. What do you think?

Perhaps okay, but why there's a limitation for hostname length?

james2001 commented 8 months ago

Hello

This domain is valide xn--c1aafynu.xn--c1avg.xn--p1acf, but the regex doesn't match because the xn part is not in the TDL -> ^(([\w\d_-]+){1,63}.)+([\w\d_-]+){2,63}$

Why the lib, don't use https://www.php.net/manual/en/filter.filters.validate.php

james2001 commented 7 months ago

@xiaohuilam can you test https://github.com/bluelibraries/dns/pull/3 ?

xiaohuilam commented 7 months ago

@xiaohuilam can you test #3 ?

@james2001 I think this is better.

filter_var($hostName, FILTER_VALIDATE_DOMAIN)

because it will return false if $hostName = '_dnsauth.test.com' in your code:

$hostName = '_dnsauth.test.com';
var_dump(filter_var($hostName, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)); // it returns `false`, and unexpected.

_dnsauth is digicert's domain validation hostname prefix, it's allowed to be created as dns host for mostly dns service providers.

and, please mention @bluelibraries for more review because he is the owner of this repository.

james2001 commented 2 weeks ago

@xiaohuilam I fix it, but un didn't understand. _dnsauth.test.com is not a valide hostname (RFC 1034 et 1035). Perhaps rename the method, to be more explicite