/** * Alias of {@link Infrastructure}::percentDecode(). * @param string $input * @return string A UTF-8 string if the $input contains only bytes in the range 0x00 to 0x7F. */ public static function percentDecode($input) { return Infrastructure::percentDecode($input); }
/** * The host parser. * @link https://url.spec.whatwg.org/#concept-host-parser URL Standard * @param string $input A UTF-8 string. * @param boolean $unicodeFlag If true, can return a domain containing non-ASCII characters. * @return string|integer|float|integer[] * If host is IPv4 address, returns a 32-bit unsigned integer (an integer or float). * If host is IPv6 address, returns an array of a 16-bit unsigned integer. */ public static function parseHost($input, $unicodeFlag = false) { $inputString = (string) $input; if ($inputString === '') { $result = false; } elseif ($inputString[0] === '[') { $result = substr($inputString, -1) !== ']' ? false : self::parseIPv6(substr($inputString, 1, -1)); } else { $domain = Infrastructure::percentDecode($input); $asciiDomain = self::domainToASCII($domain); if ($asciiDomain === false || strpbrk($asciiDomain, "\t\n\r #%/:?@[\\]") !== false) { $result = false; } else { $ipv4Host = self::parseIPv4($asciiDomain); $result = is_string($ipv4Host) ? $unicodeFlag ? self::domainToUnicode($ipv4Host) : $ipv4Host : $ipv4Host; } } return $result; }