Aggiornato Composer
This commit is contained in:
71
vendor/symfony/http-foundation/Request.php
vendored
71
vendor/symfony/http-foundation/Request.php
vendored
@@ -191,7 +191,7 @@ class Request
|
||||
protected $session;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
protected $locale;
|
||||
|
||||
@@ -246,6 +246,9 @@ class Request
|
||||
self::HEADER_X_FORWARDED_PREFIX => 'X_FORWARDED_PREFIX',
|
||||
];
|
||||
|
||||
/** @var bool */
|
||||
private $isIisRewrite = false;
|
||||
|
||||
/**
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
@@ -439,16 +442,16 @@ class Request
|
||||
/**
|
||||
* Clones a request and overrides some of its parameters.
|
||||
*
|
||||
* @param array $query The GET parameters
|
||||
* @param array $request The POST parameters
|
||||
* @param array $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array $cookies The COOKIE parameters
|
||||
* @param array $files The FILES parameters
|
||||
* @param array $server The SERVER parameters
|
||||
* @param array|null $query The GET parameters
|
||||
* @param array|null $request The POST parameters
|
||||
* @param array|null $attributes The request attributes (parameters parsed from the PATH_INFO, ...)
|
||||
* @param array|null $cookies The COOKIE parameters
|
||||
* @param array|null $files The FILES parameters
|
||||
* @param array|null $server The SERVER parameters
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public function duplicate(array $query = null, array $request = null, array $attributes = null, array $cookies = null, array $files = null, array $server = null)
|
||||
public function duplicate(?array $query = null, ?array $request = null, ?array $attributes = null, ?array $cookies = null, ?array $files = null, ?array $server = null)
|
||||
{
|
||||
$dup = clone $this;
|
||||
if (null !== $query) {
|
||||
@@ -522,10 +525,10 @@ class Request
|
||||
$cookies = [];
|
||||
|
||||
foreach ($this->cookies as $k => $v) {
|
||||
$cookies[] = $k.'='.$v;
|
||||
$cookies[] = \is_array($v) ? http_build_query([$k => $v], '', '; ', \PHP_QUERY_RFC3986) : "$k=$v";
|
||||
}
|
||||
|
||||
if (!empty($cookies)) {
|
||||
if ($cookies) {
|
||||
$cookieHeader = 'Cookie: '.implode('; ', $cookies)."\r\n";
|
||||
}
|
||||
|
||||
@@ -562,7 +565,7 @@ class Request
|
||||
|
||||
$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 = [[]];
|
||||
@@ -1452,7 +1455,7 @@ class Request
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return null === $this->locale ? $this->defaultLocale : $this->locale;
|
||||
return $this->locale ?? $this->defaultLocale;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1573,9 +1576,9 @@ class Request
|
||||
/**
|
||||
* Gets the request body decoded as array, typically from a JSON payload.
|
||||
*
|
||||
* @throws JsonException When the body cannot be decoded to an array
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws JsonException When the body cannot be decoded to an array
|
||||
*/
|
||||
public function toArray()
|
||||
{
|
||||
@@ -1648,7 +1651,7 @@ class Request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getPreferredLanguage(array $locales = null)
|
||||
public function getPreferredLanguage(?array $locales = null)
|
||||
{
|
||||
$preferredLanguages = $this->getLanguages();
|
||||
|
||||
@@ -1689,7 +1692,8 @@ class Request
|
||||
|
||||
$languages = AcceptHeader::fromString($this->headers->get('Accept-Language'))->all();
|
||||
$this->languages = [];
|
||||
foreach ($languages as $lang => $acceptHeaderItem) {
|
||||
foreach ($languages as $acceptHeaderItem) {
|
||||
$lang = $acceptHeaderItem->getValue();
|
||||
if (str_contains($lang, '-')) {
|
||||
$codes = explode('-', $lang);
|
||||
if ('i' === $codes[0]) {
|
||||
@@ -1727,7 +1731,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1741,7 +1745,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1755,7 +1759,7 @@ 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()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1804,11 +1808,10 @@ class Request
|
||||
{
|
||||
$requestUri = '';
|
||||
|
||||
if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
|
||||
if ($this->isIisRewrite() && '' != $this->server->get('UNENCODED_URL')) {
|
||||
// IIS7 with URL Rewrite: make sure we get the unencoded URL (double slash problem)
|
||||
$requestUri = $this->server->get('UNENCODED_URL');
|
||||
$this->server->remove('UNENCODED_URL');
|
||||
$this->server->remove('IIS_WasUrlRewritten');
|
||||
} elseif ($this->server->has('REQUEST_URI')) {
|
||||
$requestUri = $this->server->get('REQUEST_URI');
|
||||
|
||||
@@ -2011,7 +2014,13 @@ class Request
|
||||
*/
|
||||
private function getUrlencodedPrefix(string $string, string $prefix): ?string
|
||||
{
|
||||
if (!str_starts_with(rawurldecode($string), $prefix)) {
|
||||
if ($this->isIisRewrite()) {
|
||||
// ISS with UrlRewriteModule might report SCRIPT_NAME/PHP_SELF with wrong case
|
||||
// see https://github.com/php/php-src/issues/11981
|
||||
if (0 !== stripos(rawurldecode($string), $prefix)) {
|
||||
return null;
|
||||
}
|
||||
} elseif (!str_starts_with(rawurldecode($string), $prefix)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2052,7 +2061,7 @@ class Request
|
||||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR', ''), self::$trustedProxies);
|
||||
}
|
||||
|
||||
private function getTrustedValues(int $type, string $ip = null): array
|
||||
private function getTrustedValues(int $type, ?string $ip = null): array
|
||||
{
|
||||
$clientValues = [];
|
||||
$forwardedValues = [];
|
||||
@@ -2144,4 +2153,20 @@ class Request
|
||||
// Now the IP chain contains only untrusted proxies and the client IP
|
||||
return $clientIps ? array_reverse($clientIps) : [$firstTrustedIp];
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this IIS with UrlRewriteModule?
|
||||
*
|
||||
* This method consumes, caches and removed the IIS_WasUrlRewritten env var,
|
||||
* so we don't inherit it to sub-requests.
|
||||
*/
|
||||
private function isIisRewrite(): bool
|
||||
{
|
||||
if (1 === $this->server->getInt('IIS_WasUrlRewritten')) {
|
||||
$this->isIisRewrite = true;
|
||||
$this->server->remove('IIS_WasUrlRewritten');
|
||||
}
|
||||
|
||||
return $this->isIisRewrite;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user