updated-packages
This commit is contained in:
424
vendor/symfony/http-foundation/Request.php
vendored
424
vendor/symfony/http-foundation/Request.php
vendored
@@ -15,6 +15,14 @@ use Symfony\Component\HttpFoundation\Exception\ConflictingHeadersException;
|
||||
use Symfony\Component\HttpFoundation\Exception\SuspiciousOperationException;
|
||||
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
|
||||
// Help opcache.preload discover always-needed symbols
|
||||
class_exists(AcceptHeader::class);
|
||||
class_exists(FileBag::class);
|
||||
class_exists(HeaderBag::class);
|
||||
class_exists(HeaderUtils::class);
|
||||
class_exists(ParameterBag::class);
|
||||
class_exists(ServerBag::class);
|
||||
|
||||
/**
|
||||
* Request represents an HTTP request.
|
||||
*
|
||||
@@ -30,88 +38,88 @@ use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||
*/
|
||||
class Request
|
||||
{
|
||||
const HEADER_FORWARDED = 0b00001; // When using RFC 7239
|
||||
const HEADER_X_FORWARDED_FOR = 0b00010;
|
||||
const HEADER_X_FORWARDED_HOST = 0b00100;
|
||||
const HEADER_X_FORWARDED_PROTO = 0b01000;
|
||||
const HEADER_X_FORWARDED_PORT = 0b10000;
|
||||
const HEADER_X_FORWARDED_ALL = 0b11110; // All "X-Forwarded-*" headers
|
||||
const HEADER_X_FORWARDED_AWS_ELB = 0b11010; // AWS ELB doesn't send X-Forwarded-Host
|
||||
public const HEADER_FORWARDED = 0b00001; // When using RFC 7239
|
||||
public const HEADER_X_FORWARDED_FOR = 0b00010;
|
||||
public const HEADER_X_FORWARDED_HOST = 0b00100;
|
||||
public const HEADER_X_FORWARDED_PROTO = 0b01000;
|
||||
public const HEADER_X_FORWARDED_PORT = 0b10000;
|
||||
public const HEADER_X_FORWARDED_ALL = 0b11110; // All "X-Forwarded-*" headers
|
||||
public const HEADER_X_FORWARDED_AWS_ELB = 0b11010; // AWS ELB doesn't send X-Forwarded-Host
|
||||
|
||||
const METHOD_HEAD = 'HEAD';
|
||||
const METHOD_GET = 'GET';
|
||||
const METHOD_POST = 'POST';
|
||||
const METHOD_PUT = 'PUT';
|
||||
const METHOD_PATCH = 'PATCH';
|
||||
const METHOD_DELETE = 'DELETE';
|
||||
const METHOD_PURGE = 'PURGE';
|
||||
const METHOD_OPTIONS = 'OPTIONS';
|
||||
const METHOD_TRACE = 'TRACE';
|
||||
const METHOD_CONNECT = 'CONNECT';
|
||||
public const METHOD_HEAD = 'HEAD';
|
||||
public const METHOD_GET = 'GET';
|
||||
public const METHOD_POST = 'POST';
|
||||
public const METHOD_PUT = 'PUT';
|
||||
public const METHOD_PATCH = 'PATCH';
|
||||
public const METHOD_DELETE = 'DELETE';
|
||||
public const METHOD_PURGE = 'PURGE';
|
||||
public const METHOD_OPTIONS = 'OPTIONS';
|
||||
public const METHOD_TRACE = 'TRACE';
|
||||
public const METHOD_CONNECT = 'CONNECT';
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $trustedProxies = array();
|
||||
protected static $trustedProxies = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $trustedHostPatterns = array();
|
||||
protected static $trustedHostPatterns = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
protected static $trustedHosts = array();
|
||||
protected static $trustedHosts = [];
|
||||
|
||||
protected static $httpMethodParameterOverride = false;
|
||||
|
||||
/**
|
||||
* Custom parameters.
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
* @var ParameterBag
|
||||
*/
|
||||
public $attributes;
|
||||
|
||||
/**
|
||||
* Request body parameters ($_POST).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
* @var ParameterBag
|
||||
*/
|
||||
public $request;
|
||||
|
||||
/**
|
||||
* Query string parameters ($_GET).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
* @var ParameterBag
|
||||
*/
|
||||
public $query;
|
||||
|
||||
/**
|
||||
* Server and execution environment parameters ($_SERVER).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ServerBag
|
||||
* @var ServerBag
|
||||
*/
|
||||
public $server;
|
||||
|
||||
/**
|
||||
* Uploaded files ($_FILES).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\FileBag
|
||||
* @var FileBag
|
||||
*/
|
||||
public $files;
|
||||
|
||||
/**
|
||||
* Cookies ($_COOKIE).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\ParameterBag
|
||||
* @var ParameterBag
|
||||
*/
|
||||
public $cookies;
|
||||
|
||||
/**
|
||||
* Headers (taken from the $_SERVER).
|
||||
*
|
||||
* @var \Symfony\Component\HttpFoundation\HeaderBag
|
||||
* @var HeaderBag
|
||||
*/
|
||||
public $headers;
|
||||
|
||||
@@ -171,7 +179,7 @@ class Request
|
||||
protected $format;
|
||||
|
||||
/**
|
||||
* @var \Symfony\Component\HttpFoundation\Session\SessionInterface
|
||||
* @var SessionInterface|callable
|
||||
*/
|
||||
protected $session;
|
||||
|
||||
@@ -192,17 +200,21 @@ class Request
|
||||
|
||||
protected static $requestFactory;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $preferredFormat;
|
||||
private $isHostValid = true;
|
||||
private $isForwardedValid = true;
|
||||
|
||||
private static $trustedHeaderSet = -1;
|
||||
|
||||
private static $forwardedParams = array(
|
||||
private const FORWARDED_PARAMS = [
|
||||
self::HEADER_X_FORWARDED_FOR => 'for',
|
||||
self::HEADER_X_FORWARDED_HOST => 'host',
|
||||
self::HEADER_X_FORWARDED_PROTO => 'proto',
|
||||
self::HEADER_X_FORWARDED_PORT => 'host',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* Names for headers that can be trusted when
|
||||
@@ -213,13 +225,13 @@ class Request
|
||||
* The other headers are non-standard, but widely used
|
||||
* by popular reverse proxies (like Apache mod_proxy or Amazon EC2).
|
||||
*/
|
||||
private static $trustedHeaders = array(
|
||||
private const TRUSTED_HEADERS = [
|
||||
self::HEADER_FORWARDED => 'FORWARDED',
|
||||
self::HEADER_X_FORWARDED_FOR => 'X_FORWARDED_FOR',
|
||||
self::HEADER_X_FORWARDED_HOST => 'X_FORWARDED_HOST',
|
||||
self::HEADER_X_FORWARDED_PROTO => 'X_FORWARDED_PROTO',
|
||||
self::HEADER_X_FORWARDED_PORT => 'X_FORWARDED_PORT',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param array $query The GET parameters
|
||||
@@ -230,7 +242,7 @@ class Request
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource|null $content The raw body data
|
||||
*/
|
||||
public function __construct(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
public function __construct(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
|
||||
{
|
||||
$this->initialize($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
}
|
||||
@@ -248,7 +260,7 @@ class Request
|
||||
* @param array $server The SERVER parameters
|
||||
* @param string|resource|null $content The raw body data
|
||||
*/
|
||||
public function initialize(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
public function initialize(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null)
|
||||
{
|
||||
$this->request = new ParameterBag($request);
|
||||
$this->query = new ParameterBag($query);
|
||||
@@ -278,10 +290,10 @@ class Request
|
||||
*/
|
||||
public static function createFromGlobals()
|
||||
{
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, [], $_COOKIE, $_FILES, $_SERVER);
|
||||
|
||||
if (0 === strpos($request->headers->get('CONTENT_TYPE'), 'application/x-www-form-urlencoded')
|
||||
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
if (str_starts_with($request->headers->get('CONTENT_TYPE', ''), 'application/x-www-form-urlencoded')
|
||||
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), ['PUT', 'DELETE', 'PATCH'])
|
||||
) {
|
||||
parse_str($request->getContent(), $data);
|
||||
$request->request = new ParameterBag($data);
|
||||
@@ -306,9 +318,9 @@ class Request
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function create($uri, $method = 'GET', $parameters = array(), $cookies = array(), $files = array(), $server = array(), $content = null)
|
||||
public static function create($uri, $method = 'GET', $parameters = [], $cookies = [], $files = [], $server = [], $content = null)
|
||||
{
|
||||
$server = array_replace(array(
|
||||
$server = array_replace([
|
||||
'SERVER_NAME' => 'localhost',
|
||||
'SERVER_PORT' => 80,
|
||||
'HTTP_HOST' => 'localhost',
|
||||
@@ -321,7 +333,8 @@ class Request
|
||||
'SCRIPT_FILENAME' => '',
|
||||
'SERVER_PROTOCOL' => 'HTTP/1.1',
|
||||
'REQUEST_TIME' => time(),
|
||||
), $server);
|
||||
'REQUEST_TIME_FLOAT' => microtime(true),
|
||||
], $server);
|
||||
|
||||
$server['PATH_INFO'] = '';
|
||||
$server['REQUEST_METHOD'] = strtoupper($method);
|
||||
@@ -369,10 +382,10 @@ class Request
|
||||
// no break
|
||||
case 'PATCH':
|
||||
$request = $parameters;
|
||||
$query = array();
|
||||
$query = [];
|
||||
break;
|
||||
default:
|
||||
$request = array();
|
||||
$request = [];
|
||||
$query = $parameters;
|
||||
break;
|
||||
}
|
||||
@@ -395,7 +408,7 @@ class Request
|
||||
$server['REQUEST_URI'] = $components['path'].('' !== $queryString ? '?'.$queryString : '');
|
||||
$server['QUERY_STRING'] = $queryString;
|
||||
|
||||
return self::createRequestFromFactory($query, $request, array(), $cookies, $files, $server, $content);
|
||||
return self::createRequestFromFactory($query, $request, [], $cookies, $files, $server, $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -492,14 +505,10 @@ class Request
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
try {
|
||||
$content = $this->getContent();
|
||||
} catch (\LogicException $e) {
|
||||
return trigger_error($e, E_USER_ERROR);
|
||||
}
|
||||
$content = $this->getContent();
|
||||
|
||||
$cookieHeader = '';
|
||||
$cookies = array();
|
||||
$cookies = [];
|
||||
|
||||
foreach ($this->cookies as $k => $v) {
|
||||
$cookies[] = $k.'='.$v;
|
||||
@@ -533,19 +542,19 @@ class Request
|
||||
|
||||
foreach ($this->headers->all() as $key => $value) {
|
||||
$key = strtoupper(str_replace('-', '_', $key));
|
||||
if (\in_array($key, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
|
||||
if (\in_array($key, ['CONTENT_TYPE', 'CONTENT_LENGTH', 'CONTENT_MD5'], true)) {
|
||||
$_SERVER[$key] = implode(', ', $value);
|
||||
} else {
|
||||
$_SERVER['HTTP_'.$key] = implode(', ', $value);
|
||||
}
|
||||
}
|
||||
|
||||
$request = array('g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE);
|
||||
$request = ['g' => $_GET, 'p' => $_POST, 'c' => $_COOKIE];
|
||||
|
||||
$requestOrder = ini_get('request_order') ?: ini_get('variables_order');
|
||||
$requestOrder = \ini_get('request_order') ?: \ini_get('variables_order');
|
||||
$requestOrder = preg_replace('#[^cgp]#', '', strtolower($requestOrder)) ?: 'gp';
|
||||
|
||||
$_REQUEST = array(array());
|
||||
$_REQUEST = [[]];
|
||||
|
||||
foreach (str_split($requestOrder) as $order) {
|
||||
$_REQUEST[] = $request[$order];
|
||||
@@ -559,14 +568,20 @@ class Request
|
||||
*
|
||||
* You should only list the reverse proxies that you manage directly.
|
||||
*
|
||||
* @param array $proxies A list of trusted proxies
|
||||
* @param array $proxies A list of trusted proxies, the string 'REMOTE_ADDR' will be replaced with $_SERVER['REMOTE_ADDR']
|
||||
* @param int $trustedHeaderSet A bit field of Request::HEADER_*, to set which headers to trust from your proxies
|
||||
*
|
||||
* @throws \InvalidArgumentException When $trustedHeaderSet is invalid
|
||||
*/
|
||||
public static function setTrustedProxies(array $proxies, int $trustedHeaderSet)
|
||||
{
|
||||
self::$trustedProxies = $proxies;
|
||||
self::$trustedProxies = array_reduce($proxies, function ($proxies, $proxy) {
|
||||
if ('REMOTE_ADDR' !== $proxy) {
|
||||
$proxies[] = $proxy;
|
||||
} elseif (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$proxies[] = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
|
||||
return $proxies;
|
||||
}, []);
|
||||
self::$trustedHeaderSet = $trustedHeaderSet;
|
||||
}
|
||||
|
||||
@@ -603,7 +618,7 @@ class Request
|
||||
return sprintf('{%s}i', $hostPattern);
|
||||
}, $hostPatterns);
|
||||
// we need to reset trusted hosts on trusted host patterns change
|
||||
self::$trustedHosts = array();
|
||||
self::$trustedHosts = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -628,14 +643,14 @@ class Request
|
||||
*/
|
||||
public static function normalizeQueryString($qs)
|
||||
{
|
||||
if ('' == $qs) {
|
||||
if ('' === ($qs ?? '')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
parse_str($qs, $qs);
|
||||
ksort($qs);
|
||||
|
||||
return http_build_query($qs, '', '&', PHP_QUERY_RFC3986);
|
||||
return http_build_query($qs, '', '&', \PHP_QUERY_RFC3986);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -671,7 +686,7 @@ class Request
|
||||
* flexibility in controllers, it is better to explicitly get request parameters from the appropriate
|
||||
* public property instead (attributes, query, request).
|
||||
*
|
||||
* Order of precedence: PATH (routing placeholders or custom attributes), GET, BODY
|
||||
* Order of precedence: PATH (routing placeholders or custom attributes), GET, POST
|
||||
*
|
||||
* @param string $key The key
|
||||
* @param mixed $default The default value if the parameter key does not exist
|
||||
@@ -698,7 +713,7 @@ class Request
|
||||
/**
|
||||
* Gets the Session.
|
||||
*
|
||||
* @return SessionInterface|null The session
|
||||
* @return SessionInterface The session
|
||||
*/
|
||||
public function getSession()
|
||||
{
|
||||
@@ -708,8 +723,8 @@ class Request
|
||||
}
|
||||
|
||||
if (null === $session) {
|
||||
@trigger_error(sprintf('Calling "%s()" when no session has been set is deprecated since Symfony 4.1 and will throw an exception in 5.0. Use "hasSession()" instead.', __METHOD__), E_USER_DEPRECATED);
|
||||
// throw new \BadMethodCallException('Session has not been set');
|
||||
@trigger_error(sprintf('Calling "%s()" when no session has been set is deprecated since Symfony 4.1 and will throw an exception in 5.0. Use "hasSession()" instead.', __METHOD__), \E_USER_DEPRECATED);
|
||||
// throw new \BadMethodCallException('Session has not been set.');
|
||||
}
|
||||
|
||||
return $session;
|
||||
@@ -741,11 +756,6 @@ class Request
|
||||
return null !== $this->session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Session.
|
||||
*
|
||||
* @param SessionInterface $session The Session
|
||||
*/
|
||||
public function setSession(SessionInterface $session)
|
||||
{
|
||||
$this->session = $session;
|
||||
@@ -777,10 +787,10 @@ class Request
|
||||
$ip = $this->server->get('REMOTE_ADDR');
|
||||
|
||||
if (!$this->isFromTrustedProxy()) {
|
||||
return array($ip);
|
||||
return [$ip];
|
||||
}
|
||||
|
||||
return $this->getTrustedValues(self::HEADER_X_FORWARDED_FOR, $ip) ?: array($ip);
|
||||
return $this->getTrustedValues(self::HEADER_X_FORWARDED_FOR, $ip) ?: [$ip];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -792,10 +802,14 @@ class Request
|
||||
* being the original client, and each successive proxy that passed the request
|
||||
* adding the IP address where it received the request from.
|
||||
*
|
||||
* If your reverse proxy uses a different header name than "X-Forwarded-For",
|
||||
* ("Client-Ip" for instance), configure it via the $trustedHeaderSet
|
||||
* argument of the Request::setTrustedProxies() method instead.
|
||||
*
|
||||
* @return string|null The client IP address
|
||||
*
|
||||
* @see getClientIps()
|
||||
* @see http://en.wikipedia.org/wiki/X-Forwarded-For
|
||||
* @see https://wikipedia.org/wiki/X-Forwarded-For
|
||||
*/
|
||||
public function getClientIp()
|
||||
{
|
||||
@@ -913,8 +927,8 @@ class Request
|
||||
$pos = strrpos($host, ':');
|
||||
}
|
||||
|
||||
if (false !== $pos) {
|
||||
return (int) substr($host, $pos + 1);
|
||||
if (false !== $pos && $port = substr($host, $pos + 1)) {
|
||||
return (int) $port;
|
||||
}
|
||||
|
||||
return 'https' === $this->getScheme() ? 443 : 80;
|
||||
@@ -943,7 +957,7 @@ class Request
|
||||
/**
|
||||
* Gets the user info.
|
||||
*
|
||||
* @return string A user name and, optionally, scheme-specific information about how to gain authorization to access the server
|
||||
* @return string|null A user name if any and, optionally, scheme-specific information about how to gain authorization to access the server
|
||||
*/
|
||||
public function getUserInfo()
|
||||
{
|
||||
@@ -1080,7 +1094,7 @@ class Request
|
||||
// A reference to the same base directory or an empty subdirectory must be prefixed with "./".
|
||||
// This also applies to a segment with a colon character (e.g., "file:colon") that cannot be used
|
||||
// as the first segment of a relative-path reference, as it would be mistaken for a scheme name
|
||||
// (see http://tools.ietf.org/html/rfc3986#section-4.2).
|
||||
// (see https://tools.ietf.org/html/rfc3986#section-4.2).
|
||||
return !isset($path[0]) || '/' === $path[0]
|
||||
|| false !== ($colonPos = strpos($path, ':')) && ($colonPos < ($slashPos = strpos($path, '/')) || false === $slashPos)
|
||||
? "./$path" : $path;
|
||||
@@ -1114,7 +1128,7 @@ class Request
|
||||
public function isSecure()
|
||||
{
|
||||
if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_X_FORWARDED_PROTO)) {
|
||||
return \in_array(strtolower($proto[0]), array('https', 'on', 'ssl', '1'), true);
|
||||
return \in_array(strtolower($proto[0]), ['https', 'on', 'ssl', '1'], true);
|
||||
}
|
||||
|
||||
$https = $this->server->get('HTTPS');
|
||||
@@ -1214,22 +1228,37 @@ class Request
|
||||
*/
|
||||
public function getMethod()
|
||||
{
|
||||
if (null === $this->method) {
|
||||
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
|
||||
|
||||
if ('POST' === $this->method) {
|
||||
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
|
||||
$this->method = strtoupper($method);
|
||||
} elseif (self::$httpMethodParameterOverride) {
|
||||
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
|
||||
if (\is_string($method)) {
|
||||
$this->method = strtoupper($method);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (null !== $this->method) {
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
return $this->method;
|
||||
$this->method = strtoupper($this->server->get('REQUEST_METHOD', 'GET'));
|
||||
|
||||
if ('POST' !== $this->method) {
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
$method = $this->headers->get('X-HTTP-METHOD-OVERRIDE');
|
||||
|
||||
if (!$method && self::$httpMethodParameterOverride) {
|
||||
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
|
||||
}
|
||||
|
||||
if (!\is_string($method)) {
|
||||
return $this->method;
|
||||
}
|
||||
|
||||
$method = strtoupper($method);
|
||||
|
||||
if (\in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'CONNECT', 'OPTIONS', 'PATCH', 'PURGE', 'TRACE'], true)) {
|
||||
return $this->method = $method;
|
||||
}
|
||||
|
||||
if (!preg_match('/^[A-Z]++$/D', $method)) {
|
||||
throw new SuspiciousOperationException(sprintf('Invalid method override "%s".', $method));
|
||||
}
|
||||
|
||||
return $this->method = $method;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1273,7 +1302,7 @@ class Request
|
||||
static::initializeFormats();
|
||||
}
|
||||
|
||||
return isset(static::$formats[$format]) ? static::$formats[$format] : array();
|
||||
return static::$formats[$format] ?? [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1302,6 +1331,8 @@ class Request
|
||||
return $format;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1316,7 +1347,7 @@ class Request
|
||||
static::initializeFormats();
|
||||
}
|
||||
|
||||
static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);
|
||||
static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : [$mimeTypes];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1328,9 +1359,11 @@ class Request
|
||||
* * _format request attribute
|
||||
* * $default
|
||||
*
|
||||
* @see getPreferredFormat
|
||||
*
|
||||
* @param string|null $default The default format
|
||||
*
|
||||
* @return string The request format
|
||||
* @return string|null The request format
|
||||
*/
|
||||
public function getRequestFormat($default = 'html')
|
||||
{
|
||||
@@ -1338,7 +1371,7 @@ class Request
|
||||
$this->format = $this->attributes->get('_format');
|
||||
}
|
||||
|
||||
return null === $this->format ? $default : $this->format;
|
||||
return $this->format ?? $default;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1358,7 +1391,7 @@ class Request
|
||||
*/
|
||||
public function getContentType()
|
||||
{
|
||||
return $this->getFormat($this->headers->get('CONTENT_TYPE'));
|
||||
return $this->getFormat($this->headers->get('CONTENT_TYPE', ''));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1422,18 +1455,15 @@ class Request
|
||||
*
|
||||
* @see https://tools.ietf.org/html/rfc7231#section-4.2.1
|
||||
*
|
||||
* @param bool $andCacheable Adds the additional condition that the method should be cacheable. True by default.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMethodSafe(/* $andCacheable = true */)
|
||||
public function isMethodSafe()
|
||||
{
|
||||
if (!\func_num_args() || func_get_arg(0)) {
|
||||
// setting $andCacheable to false should be deprecated in 4.1
|
||||
throw new \BadMethodCallException('Checking only for cacheable HTTP methods with Symfony\Component\HttpFoundation\Request::isMethodSafe() is not supported.');
|
||||
if (\func_num_args() > 0) {
|
||||
@trigger_error(sprintf('Passing arguments to "%s()" has been deprecated since Symfony 4.4; use "%s::isMethodCacheable()" to check if the method is cacheable instead.', __METHOD__, __CLASS__), \E_USER_DEPRECATED);
|
||||
}
|
||||
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
return \in_array($this->getMethod(), ['GET', 'HEAD', 'OPTIONS', 'TRACE']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1443,7 +1473,7 @@ class Request
|
||||
*/
|
||||
public function isMethodIdempotent()
|
||||
{
|
||||
return \in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
|
||||
return \in_array($this->getMethod(), ['HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1455,7 +1485,7 @@ class Request
|
||||
*/
|
||||
public function isMethodCacheable()
|
||||
{
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
return \in_array($this->getMethod(), ['GET', 'HEAD']);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1467,12 +1497,12 @@ class Request
|
||||
* if the proxy is trusted (see "setTrustedProxies()"), otherwise it returns
|
||||
* the latter (from the "SERVER_PROTOCOL" server parameter).
|
||||
*
|
||||
* @return string
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProtocolVersion()
|
||||
{
|
||||
if ($this->isFromTrustedProxy()) {
|
||||
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via'), $matches);
|
||||
preg_match('~^(HTTP/)?([1-9]\.[0-9]) ~', $this->headers->get('Via') ?? '', $matches);
|
||||
|
||||
if ($matches) {
|
||||
return 'HTTP/'.$matches[2];
|
||||
@@ -1488,8 +1518,6 @@ class Request
|
||||
* @param bool $asResource If true, a resource will be returned
|
||||
*
|
||||
* @return string|resource The request body content or a resource to read the body stream
|
||||
*
|
||||
* @throws \LogicException
|
||||
*/
|
||||
public function getContent($asResource = false)
|
||||
{
|
||||
@@ -1513,7 +1541,7 @@ class Request
|
||||
|
||||
$this->content = false;
|
||||
|
||||
return fopen('php://input', 'rb');
|
||||
return fopen('php://input', 'r');
|
||||
}
|
||||
|
||||
if ($currentContentIsResource) {
|
||||
@@ -1536,7 +1564,7 @@ class Request
|
||||
*/
|
||||
public function getETags()
|
||||
{
|
||||
return preg_split('/\s*,\s*/', $this->headers->get('if_none_match'), null, PREG_SPLIT_NO_EMPTY);
|
||||
return preg_split('/\s*,\s*/', $this->headers->get('If-None-Match', ''), -1, \PREG_SPLIT_NO_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1547,10 +1575,33 @@ class Request
|
||||
return $this->headers->hasCacheControlDirective('no-cache') || 'no-cache' == $this->headers->get('Pragma');
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the preferred format for the response by inspecting, in the following order:
|
||||
* * the request format set using setRequestFormat
|
||||
* * the values of the Accept HTTP header.
|
||||
*
|
||||
* Note that if you use this method, you should send the "Vary: Accept" header
|
||||
* in the response to prevent any issues with intermediary HTTP caches.
|
||||
*/
|
||||
public function getPreferredFormat(?string $default = 'html'): ?string
|
||||
{
|
||||
if (null !== $this->preferredFormat || null !== $this->preferredFormat = $this->getRequestFormat(null)) {
|
||||
return $this->preferredFormat;
|
||||
}
|
||||
|
||||
foreach ($this->getAcceptableContentTypes() as $mimeType) {
|
||||
if ($this->preferredFormat = $this->getFormat($mimeType)) {
|
||||
return $this->preferredFormat;
|
||||
}
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the preferred language.
|
||||
*
|
||||
* @param array $locales An array of ordered available locales
|
||||
* @param string[] $locales An array of ordered available locales
|
||||
*
|
||||
* @return string|null The preferred locale
|
||||
*/
|
||||
@@ -1559,14 +1610,14 @@ class Request
|
||||
$preferredLanguages = $this->getLanguages();
|
||||
|
||||
if (empty($locales)) {
|
||||
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : null;
|
||||
return $preferredLanguages[0] ?? null;
|
||||
}
|
||||
|
||||
if (!$preferredLanguages) {
|
||||
return $locales[0];
|
||||
}
|
||||
|
||||
$extendedPreferredLanguages = array();
|
||||
$extendedPreferredLanguages = [];
|
||||
foreach ($preferredLanguages as $language) {
|
||||
$extendedPreferredLanguages[] = $language;
|
||||
if (false !== $position = strpos($language, '_')) {
|
||||
@@ -1579,7 +1630,7 @@ class Request
|
||||
|
||||
$preferredLanguages = array_values(array_intersect($extendedPreferredLanguages, $locales));
|
||||
|
||||
return isset($preferredLanguages[0]) ? $preferredLanguages[0] : $locales[0];
|
||||
return $preferredLanguages[0] ?? $locales[0];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1594,9 +1645,10 @@ class Request
|
||||
}
|
||||
|
||||
$languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all();
|
||||
$this->languages = array();
|
||||
foreach ($languages as $lang => $acceptHeaderItem) {
|
||||
if (false !== strpos($lang, '-')) {
|
||||
$this->languages = [];
|
||||
foreach ($languages as $acceptHeaderItem) {
|
||||
$lang = $acceptHeaderItem->getValue();
|
||||
if (str_contains($lang, '-')) {
|
||||
$codes = explode('-', $lang);
|
||||
if ('i' === $codes[0]) {
|
||||
// Language not listed in ISO 639 that are not variants
|
||||
@@ -1633,7 +1685,7 @@ class Request
|
||||
return $this->charsets;
|
||||
}
|
||||
|
||||
return $this->charsets = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all());
|
||||
return $this->charsets = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept-Charset'))->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1647,7 +1699,7 @@ class Request
|
||||
return $this->encodings;
|
||||
}
|
||||
|
||||
return $this->encodings = array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all());
|
||||
return $this->encodings = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept-Encoding'))->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1661,16 +1713,16 @@ class Request
|
||||
return $this->acceptableContentTypes;
|
||||
}
|
||||
|
||||
return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all());
|
||||
return $this->acceptableContentTypes = array_map('strval', array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the request is a XMLHttpRequest.
|
||||
* Returns true if the request is an XMLHttpRequest.
|
||||
*
|
||||
* It works if your JavaScript library sets an X-Requested-With HTTP header.
|
||||
* It is known to work with common JavaScript frameworks:
|
||||
*
|
||||
* @see http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript
|
||||
* @see https://wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript
|
||||
*
|
||||
* @return bool true if the request is an XMLHttpRequest, false otherwise
|
||||
*/
|
||||
@@ -1682,9 +1734,9 @@ class Request
|
||||
/*
|
||||
* The following methods are derived from code of the Zend Framework (1.10dev - 2010-01-24)
|
||||
*
|
||||
* Code subject to the new BSD license (http://framework.zend.com/license/new-bsd).
|
||||
* Code subject to the new BSD license (https://framework.zend.com/license).
|
||||
*
|
||||
* Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* Copyright (c) 2005-2010 Zend Technologies USA Inc. (https://www.zend.com/)
|
||||
*/
|
||||
|
||||
protected function prepareRequestUri()
|
||||
@@ -1699,15 +1751,23 @@ class Request
|
||||
} elseif ($this->server->has('REQUEST_URI')) {
|
||||
$requestUri = $this->server->get('REQUEST_URI');
|
||||
|
||||
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
|
||||
$uriComponents = parse_url($requestUri);
|
||||
if ('' !== $requestUri && '/' === $requestUri[0]) {
|
||||
// To only use path and query remove the fragment.
|
||||
if (false !== $pos = strpos($requestUri, '#')) {
|
||||
$requestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
} else {
|
||||
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path,
|
||||
// only use URL path.
|
||||
$uriComponents = parse_url($requestUri);
|
||||
|
||||
if (isset($uriComponents['path'])) {
|
||||
$requestUri = $uriComponents['path'];
|
||||
}
|
||||
if (isset($uriComponents['path'])) {
|
||||
$requestUri = $uriComponents['path'];
|
||||
}
|
||||
|
||||
if (isset($uriComponents['query'])) {
|
||||
$requestUri .= '?'.$uriComponents['query'];
|
||||
if (isset($uriComponents['query'])) {
|
||||
$requestUri .= '?'.$uriComponents['query'];
|
||||
}
|
||||
}
|
||||
} elseif ($this->server->has('ORIG_PATH_INFO')) {
|
||||
// IIS 5.0, PHP as CGI
|
||||
@@ -1731,13 +1791,13 @@ class Request
|
||||
*/
|
||||
protected function prepareBaseUrl()
|
||||
{
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME'));
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME', ''));
|
||||
|
||||
if (basename($this->server->get('SCRIPT_NAME')) === $filename) {
|
||||
if (basename($this->server->get('SCRIPT_NAME', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('SCRIPT_NAME');
|
||||
} elseif (basename($this->server->get('PHP_SELF')) === $filename) {
|
||||
} elseif (basename($this->server->get('PHP_SELF', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('PHP_SELF');
|
||||
} elseif (basename($this->server->get('ORIG_SCRIPT_NAME')) === $filename) {
|
||||
} elseif (basename($this->server->get('ORIG_SCRIPT_NAME', '')) === $filename) {
|
||||
$baseUrl = $this->server->get('ORIG_SCRIPT_NAME'); // 1and1 shared hosting compatibility
|
||||
} else {
|
||||
// Backtrack up the script_filename to find the portion matching
|
||||
@@ -1762,12 +1822,12 @@ class Request
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
// full $baseUrl matches
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
if ($baseUrl && null !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
// directory portion of $baseUrl matches
|
||||
return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
@@ -1777,7 +1837,7 @@ class Request
|
||||
$truncatedRequestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
|
||||
$basename = basename($baseUrl);
|
||||
$basename = basename($baseUrl ?? '');
|
||||
if (empty($basename) || !strpos(rawurldecode($truncatedRequestUri), $basename)) {
|
||||
// no match whatsoever; set it blank
|
||||
return '';
|
||||
@@ -1848,7 +1908,7 @@ class Request
|
||||
return '/';
|
||||
}
|
||||
|
||||
return (string) $pathInfo;
|
||||
return $pathInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1856,44 +1916,42 @@ class Request
|
||||
*/
|
||||
protected static function initializeFormats()
|
||||
{
|
||||
static::$formats = array(
|
||||
'html' => array('text/html', 'application/xhtml+xml'),
|
||||
'txt' => array('text/plain'),
|
||||
'js' => array('application/javascript', 'application/x-javascript', 'text/javascript'),
|
||||
'css' => array('text/css'),
|
||||
'json' => array('application/json', 'application/x-json'),
|
||||
'jsonld' => array('application/ld+json'),
|
||||
'xml' => array('text/xml', 'application/xml', 'application/x-xml'),
|
||||
'rdf' => array('application/rdf+xml'),
|
||||
'atom' => array('application/atom+xml'),
|
||||
'rss' => array('application/rss+xml'),
|
||||
'form' => array('application/x-www-form-urlencoded'),
|
||||
);
|
||||
static::$formats = [
|
||||
'html' => ['text/html', 'application/xhtml+xml'],
|
||||
'txt' => ['text/plain'],
|
||||
'js' => ['application/javascript', 'application/x-javascript', 'text/javascript'],
|
||||
'css' => ['text/css'],
|
||||
'json' => ['application/json', 'application/x-json'],
|
||||
'jsonld' => ['application/ld+json'],
|
||||
'xml' => ['text/xml', 'application/xml', 'application/x-xml'],
|
||||
'rdf' => ['application/rdf+xml'],
|
||||
'atom' => ['application/atom+xml'],
|
||||
'rss' => ['application/rss+xml'],
|
||||
'form' => ['application/x-www-form-urlencoded'],
|
||||
];
|
||||
}
|
||||
|
||||
private function setPhpDefaultLocale(string $locale)
|
||||
private function setPhpDefaultLocale(string $locale): void
|
||||
{
|
||||
// if either the class Locale doesn't exist, or an exception is thrown when
|
||||
// setting the default locale, the intl module is not installed, and
|
||||
// the call can be ignored:
|
||||
try {
|
||||
if (class_exists('Locale', false)) {
|
||||
if (class_exists(\Locale::class, false)) {
|
||||
\Locale::setDefault($locale);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Returns the prefix as encoded in the string when the string starts with
|
||||
* the given prefix, false otherwise.
|
||||
*
|
||||
* @return string|false The prefix as it is encoded in $string, or false
|
||||
* the given prefix, null otherwise.
|
||||
*/
|
||||
private function getUrlencodedPrefix(string $string, string $prefix)
|
||||
private function getUrlencodedPrefix(string $string, string $prefix): ?string
|
||||
{
|
||||
if (0 !== strpos(rawurldecode($string), $prefix)) {
|
||||
return false;
|
||||
if (!str_starts_with(rawurldecode($string), $prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$len = \strlen($prefix);
|
||||
@@ -1902,13 +1960,13 @@ class Request
|
||||
return $match[0];
|
||||
}
|
||||
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
private static function createRequestFromFactory(array $query = [], array $request = [], array $attributes = [], array $cookies = [], array $files = [], array $server = [], $content = null): self
|
||||
{
|
||||
if (self::$requestFactory) {
|
||||
$request = \call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
$request = (self::$requestFactory)($query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
|
||||
if (!$request instanceof self) {
|
||||
throw new \LogicException('The Request factory must return an instance of Symfony\Component\HttpFoundation\Request.');
|
||||
@@ -1930,31 +1988,31 @@ class Request
|
||||
*/
|
||||
public function isFromTrustedProxy()
|
||||
{
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR', ''), self::$trustedProxies);
|
||||
}
|
||||
|
||||
private function getTrustedValues($type, $ip = null)
|
||||
private function getTrustedValues(int $type, string $ip = null): array
|
||||
{
|
||||
$clientValues = array();
|
||||
$forwardedValues = array();
|
||||
$clientValues = [];
|
||||
$forwardedValues = [];
|
||||
|
||||
if ((self::$trustedHeaderSet & $type) && $this->headers->has(self::$trustedHeaders[$type])) {
|
||||
foreach (explode(',', $this->headers->get(self::$trustedHeaders[$type])) as $v) {
|
||||
if ((self::$trustedHeaderSet & $type) && $this->headers->has(self::TRUSTED_HEADERS[$type])) {
|
||||
foreach (explode(',', $this->headers->get(self::TRUSTED_HEADERS[$type])) as $v) {
|
||||
$clientValues[] = (self::HEADER_X_FORWARDED_PORT === $type ? '0.0.0.0:' : '').trim($v);
|
||||
}
|
||||
}
|
||||
|
||||
if ((self::$trustedHeaderSet & self::HEADER_FORWARDED) && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) {
|
||||
$forwarded = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]);
|
||||
if ((self::$trustedHeaderSet & self::HEADER_FORWARDED) && $this->headers->has(self::TRUSTED_HEADERS[self::HEADER_FORWARDED])) {
|
||||
$forwarded = $this->headers->get(self::TRUSTED_HEADERS[self::HEADER_FORWARDED]);
|
||||
$parts = HeaderUtils::split($forwarded, ',;=');
|
||||
$forwardedValues = array();
|
||||
$param = self::$forwardedParams[$type];
|
||||
$forwardedValues = [];
|
||||
$param = self::FORWARDED_PARAMS[$type];
|
||||
foreach ($parts as $subParts) {
|
||||
if (null === $v = HeaderUtils::combine($subParts)[$param] ?? null) {
|
||||
continue;
|
||||
}
|
||||
if (self::HEADER_X_FORWARDED_PORT === $type) {
|
||||
if (']' === substr($v, -1) || false === $v = strrchr($v, ':')) {
|
||||
if (str_ends_with($v, ']') || false === $v = strrchr($v, ':')) {
|
||||
$v = $this->isSecure() ? ':443' : ':80';
|
||||
}
|
||||
$v = '0.0.0.0'.$v;
|
||||
@@ -1977,17 +2035,17 @@ class Request
|
||||
}
|
||||
|
||||
if (!$this->isForwardedValid) {
|
||||
return null !== $ip ? array('0.0.0.0', $ip) : array();
|
||||
return null !== $ip ? ['0.0.0.0', $ip] : [];
|
||||
}
|
||||
$this->isForwardedValid = false;
|
||||
|
||||
throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::$trustedHeaders[self::HEADER_FORWARDED], self::$trustedHeaders[$type]));
|
||||
throw new ConflictingHeadersException(sprintf('The request has both a trusted "%s" header and a trusted "%s" header, conflicting with each other. You should either configure your proxy to remove one of them, or configure your project to distrust the offending one.', self::TRUSTED_HEADERS[self::HEADER_FORWARDED], self::TRUSTED_HEADERS[$type]));
|
||||
}
|
||||
|
||||
private function normalizeAndFilterClientIps(array $clientIps, $ip)
|
||||
private function normalizeAndFilterClientIps(array $clientIps, string $ip): array
|
||||
{
|
||||
if (!$clientIps) {
|
||||
return array();
|
||||
return [];
|
||||
}
|
||||
$clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
|
||||
$firstTrustedIp = null;
|
||||
@@ -2000,13 +2058,13 @@ class Request
|
||||
if ($i) {
|
||||
$clientIps[$key] = $clientIp = substr($clientIp, 0, $i);
|
||||
}
|
||||
} elseif (0 === strpos($clientIp, '[')) {
|
||||
} elseif (str_starts_with($clientIp, '[')) {
|
||||
// Strip brackets and :port from IPv6 addresses.
|
||||
$i = strpos($clientIp, ']', 1);
|
||||
$clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1);
|
||||
}
|
||||
|
||||
if (!filter_var($clientIp, FILTER_VALIDATE_IP)) {
|
||||
if (!filter_var($clientIp, \FILTER_VALIDATE_IP)) {
|
||||
unset($clientIps[$key]);
|
||||
|
||||
continue;
|
||||
@@ -2023,6 +2081,6 @@ class Request
|
||||
}
|
||||
|
||||
// Now the IP chain contains only untrusted proxies and the client IP
|
||||
return $clientIps ? array_reverse($clientIps) : array($firstTrustedIp);
|
||||
return $clientIps ? array_reverse($clientIps) : [$firstTrustedIp];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user