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

Match a hostname against a dNSName reference


Description Description


Parameters Parameters

$host

(string) (Required) Requested host

$reference

(string) (Required) dNSName to match against


Top ↑

Return Return

(boolean) Does the domain match?


Top ↑

Source Source

File: wp-includes/Requests/SSL.php

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


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.