Requests_SSL::match_domain() WordPress Method

The Requests_SSL::match_domain() method is used to match a domain name against a list of pre-defined domains. This is useful for checking if a given domain is allowed to access a given resource.

Requests_SSL::match_domain( string $host, string $reference ) #

Match a hostname against a dNSName reference


Parameters

$host

(string)(Required)Requested host

$reference

(string)(Required)dNSName to match against


Top ↑

Return

(boolean) Does the domain match?


Top ↑

Source

File: wp-includes/Requests/SSL.php

	public static function match_domain($host, $reference) {
		// Check if the reference is blocklisted first
		if (self::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;
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.