Requests_SSL::match_domain() – Match a hostname against a dNSName reference

You appear to be a bot. Output may be restricted

Description

Match a hostname against a dNSName reference

Usage

$boolean = Requests_SSL::match_domain( $host, $reference );

Parameters

$host
( string ) required – Requested host
$reference
( string ) required – dNSName to match against

Returns

boolean Does the domain match?

Source

File name: wordpress/wp-includes/Requests/SSL.php


Lines:

1 to 26 of 26
  public static function match_domain($host, $reference) {
    // Check if the reference is blocklisted first
    if (self::Requests_SSL::verify_reference_name($reference) !== true) {
      return false;
    }

    // Check for a direct match
    if ($host === $reference) {
      return true;
    }

    // Calculate the valid wildcard match if the host is not an IP address
    // Also validates that the host has 3 parts or more, as per Firefox's
    // ruleset.
    if (ip2long($host) === false) {
      $parts    = explode('.', $host);
      $parts[0] = '*';
      $wildcard = implode('.', $parts);
      if ($wildcard === $reference) {
        return true;
      }
    }

    return false;
  }
 

 View on GitHub View on Trac