Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/updraftp.../vendor/guzzleht.../guzzle/src
File: Utils.php
<?php
[0] Fix | Delete
namespace GuzzleHttp;
[1] Fix | Delete
[2] Fix | Delete
use GuzzleHttp\Exception\InvalidArgumentException;
[3] Fix | Delete
use Psr\Http\Message\UriInterface;
[4] Fix | Delete
use Symfony\Polyfill\Intl\Idn\Idn;
[5] Fix | Delete
[6] Fix | Delete
final class Utils
[7] Fix | Delete
{
[8] Fix | Delete
/**
[9] Fix | Delete
* Wrapper for the hrtime() or microtime() functions
[10] Fix | Delete
* (depending on the PHP version, one of the two is used)
[11] Fix | Delete
*
[12] Fix | Delete
* @return float|mixed UNIX timestamp
[13] Fix | Delete
*
[14] Fix | Delete
* @internal
[15] Fix | Delete
*/
[16] Fix | Delete
public static function currentTime()
[17] Fix | Delete
{
[18] Fix | Delete
return function_exists('hrtime') ? hrtime(true) / 1e9 : microtime(true);
[19] Fix | Delete
}
[20] Fix | Delete
[21] Fix | Delete
/**
[22] Fix | Delete
* @param int $options
[23] Fix | Delete
*
[24] Fix | Delete
* @return UriInterface
[25] Fix | Delete
* @throws InvalidArgumentException
[26] Fix | Delete
*
[27] Fix | Delete
* @internal
[28] Fix | Delete
*/
[29] Fix | Delete
public static function idnUriConvert(UriInterface $uri, $options = 0)
[30] Fix | Delete
{
[31] Fix | Delete
if ($uri->getHost()) {
[32] Fix | Delete
$asciiHost = self::idnToAsci($uri->getHost(), $options, $info);
[33] Fix | Delete
if ($asciiHost === false) {
[34] Fix | Delete
$errorBitSet = isset($info['errors']) ? $info['errors'] : 0;
[35] Fix | Delete
[36] Fix | Delete
$errorConstants = array_filter(array_keys(get_defined_constants()), function ($name) {
[37] Fix | Delete
return substr($name, 0, 11) === 'IDNA_ERROR_';
[38] Fix | Delete
});
[39] Fix | Delete
[40] Fix | Delete
$errors = [];
[41] Fix | Delete
foreach ($errorConstants as $errorConstant) {
[42] Fix | Delete
if ($errorBitSet & constant($errorConstant)) {
[43] Fix | Delete
$errors[] = $errorConstant;
[44] Fix | Delete
}
[45] Fix | Delete
}
[46] Fix | Delete
[47] Fix | Delete
$errorMessage = 'IDN conversion failed';
[48] Fix | Delete
if ($errors) {
[49] Fix | Delete
$errorMessage .= ' (errors: ' . implode(', ', $errors) . ')';
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
throw new InvalidArgumentException($errorMessage);
[53] Fix | Delete
} else {
[54] Fix | Delete
if ($uri->getHost() !== $asciiHost) {
[55] Fix | Delete
// Replace URI only if the ASCII version is different
[56] Fix | Delete
$uri = $uri->withHost($asciiHost);
[57] Fix | Delete
}
[58] Fix | Delete
}
[59] Fix | Delete
}
[60] Fix | Delete
[61] Fix | Delete
return $uri;
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
/**
[65] Fix | Delete
* @param string $domain
[66] Fix | Delete
* @param int $options
[67] Fix | Delete
* @param array $info
[68] Fix | Delete
*
[69] Fix | Delete
* @return string|false
[70] Fix | Delete
*/
[71] Fix | Delete
private static function idnToAsci($domain, $options, &$info = [])
[72] Fix | Delete
{
[73] Fix | Delete
if (\preg_match('%^[ -~]+$%', $domain) === 1) {
[74] Fix | Delete
return $domain;
[75] Fix | Delete
}
[76] Fix | Delete
[77] Fix | Delete
if (\extension_loaded('intl') && defined('INTL_IDNA_VARIANT_UTS46')) {
[78] Fix | Delete
return \idn_to_ascii($domain, $options, INTL_IDNA_VARIANT_UTS46, $info);
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
/*
[82] Fix | Delete
* The Idn class is marked as @internal. Verify that class and method exists.
[83] Fix | Delete
*/
[84] Fix | Delete
if (method_exists(Idn::class, 'idn_to_ascii')) {
[85] Fix | Delete
return Idn::idn_to_ascii($domain, $options, Idn::INTL_IDNA_VARIANT_UTS46, $info);
[86] Fix | Delete
}
[87] Fix | Delete
[88] Fix | Delete
throw new \RuntimeException('ext-intl or symfony/polyfill-intl-idn not loaded or too old');
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function