Skip to content

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

Description

@xiaohuilam

if (!preg_match(Regex::DOMAIN_OR_SUBDOMAIN, $hostName)) {
throw new DnsHandlerException(
$hostnameErrorInfo . ' format! (characters "A-Za-z0-9.-", max length 63 chars allowed)',
DnsHandlerException::HOSTNAME_FORMAT_INVALID
);
}

Activity

  1. bluelibraries commented on Jun 19, 2023

    @bluelibraries
    Owner

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

  2. bluelibraries commented on Jun 19, 2023

    @bluelibraries
    Owner

    I'm on it.

  3. xiaohuilam commented on Jun 20, 2023

    @xiaohuilam
    Author

    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?

  4. added a commit that references this issue on Oct 1, 2023
  5. james2001 commented on Jan 24, 2024

    @james2001

    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

  6. james2001 commented on Mar 4, 2024

    @james2001

    @xiaohuilam can you test #3 ?

  7. xiaohuilam commented on Mar 12, 2024

    @xiaohuilam
    Author

    @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.

  8. james2001 commented on Oct 2, 2024

    @james2001

    @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

  9. xiaohuilam commented on Oct 18, 2024

    @xiaohuilam
    Author

    @james2001

    _dnsauth.test.com is not a valide hostname (RFC 1034 et 1035)

    _dnsauth is the solid dns hostname implemented by DigiCert (a ssl certificate authority) which using to validate(DNS method) domain names, I found this bug when i tried your PR at my SSL reselling project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions