Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Idn.php

function Idn::validateDomainAndLabelLength

Parameters

array<int, string> $labels:

1 call to Idn::validateDomainAndLabelLength()
Idn::idn_to_ascii in vendor/symfony/polyfill-intl-idn/Idn.php

File

vendor/symfony/polyfill-intl-idn/Idn.php, line 456

Class

Idn
@internal

Namespace

Symfony\Polyfill\Intl\Idn

Code

private static function validateDomainAndLabelLength(array $labels, Info $info) {
    $maxDomainSize = self::MAX_DOMAIN_SIZE;
    $length = \count($labels);
    // Number of "." delimiters.
    $domainLength = $length - 1;
    // If the last label is empty and it is not the first label, then it is the root label.
    // Increase the max size by 1, making it 254, to account for the root label's "."
    // delimiter. This also means we don't need to check the last label's length for being too
    // long.
    if ($length > 1 && '' === $labels[$length - 1]) {
        ++$maxDomainSize;
        --$length;
    }
    for ($i = 0; $i < $length; ++$i) {
        $bytes = \strlen($labels[$i]);
        $domainLength += $bytes;
        if ($bytes > self::MAX_LABEL_SIZE) {
            $info->errors |= self::ERROR_LABEL_TOO_LONG;
        }
    }
    if ($domainLength > $maxDomainSize) {
        $info->errors |= self::ERROR_DOMAIN_NAME_TOO_LONG;
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal