upgraded dependencies
This commit is contained in:
45
vendor/symfony/http-foundation/IpUtils.php
vendored
45
vendor/symfony/http-foundation/IpUtils.php
vendored
@@ -30,14 +30,15 @@ class IpUtils
|
||||
/**
|
||||
* Checks if an IPv4 or IPv6 address is contained in the list of given IPs or subnets.
|
||||
*
|
||||
* @param string $requestIp IP to check
|
||||
* @param string|array $ips List of IPs or subnets (can be a string if only a single one)
|
||||
* @param string|array $ips List of IPs or subnets (can be a string if only a single one)
|
||||
*
|
||||
* @return bool Whether the IP is valid
|
||||
* @return bool
|
||||
*/
|
||||
public static function checkIp($requestIp, $ips)
|
||||
public static function checkIp(?string $requestIp, $ips)
|
||||
{
|
||||
if (null === $requestIp) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -60,13 +61,18 @@ class IpUtils
|
||||
* Compares two IPv4 addresses.
|
||||
* In case a subnet is given, it checks if it contains the request IP.
|
||||
*
|
||||
* @param string $requestIp IPv4 address to check
|
||||
* @param string $ip IPv4 address or subnet in CIDR notation
|
||||
* @param string $ip IPv4 address or subnet in CIDR notation
|
||||
*
|
||||
* @return bool Whether the request IP matches the IP, or whether the request IP is within the CIDR subnet
|
||||
*/
|
||||
public static function checkIp4($requestIp, $ip)
|
||||
public static function checkIp4(?string $requestIp, string $ip)
|
||||
{
|
||||
if (null === $requestIp) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheKey = $requestIp.'-'.$ip;
|
||||
if (isset(self::$checkedIps[$cacheKey])) {
|
||||
return self::$checkedIps[$cacheKey];
|
||||
@@ -106,15 +112,20 @@ class IpUtils
|
||||
*
|
||||
* @see https://github.com/dsp/v6tools
|
||||
*
|
||||
* @param string $requestIp IPv6 address to check
|
||||
* @param string $ip IPv6 address or subnet in CIDR notation
|
||||
* @param string $ip IPv6 address or subnet in CIDR notation
|
||||
*
|
||||
* @return bool Whether the IP is valid
|
||||
* @return bool
|
||||
*
|
||||
* @throws \RuntimeException When IPV6 support is not enabled
|
||||
*/
|
||||
public static function checkIp6($requestIp, $ip)
|
||||
public static function checkIp6(?string $requestIp, string $ip)
|
||||
{
|
||||
if (null === $requestIp) {
|
||||
trigger_deprecation('symfony/http-foundation', '5.4', 'Passing null as $requestIp to "%s()" is deprecated, pass an empty string instead.', __METHOD__);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
$cacheKey = $requestIp.'-'.$ip;
|
||||
if (isset(self::$checkedIps[$cacheKey])) {
|
||||
return self::$checkedIps[$cacheKey];
|
||||
@@ -125,10 +136,6 @@ class IpUtils
|
||||
}
|
||||
|
||||
// Check to see if we were given a IP4 $requestIp or $ip by mistake
|
||||
if (str_contains($requestIp, '.') || str_contains($ip, '.')) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
@@ -136,6 +143,10 @@ class IpUtils
|
||||
if (str_contains($ip, '/')) {
|
||||
[$address, $netmask] = explode('/', $ip, 2);
|
||||
|
||||
if (!filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
if ('0' === $netmask) {
|
||||
return (bool) unpack('n*', @inet_pton($address));
|
||||
}
|
||||
@@ -144,6 +155,10 @@ class IpUtils
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
} else {
|
||||
if (!filter_var($ip, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
$address = $ip;
|
||||
$netmask = 128;
|
||||
}
|
||||
|
Reference in New Issue
Block a user