Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
web/vendor/symfony/http-foundation
|
@ -164,7 +164,7 @@ class BinaryFileResponse extends Response
|
|||
if ('' === $filenameFallback && (!preg_match('/^[\x20-\x7e]*$/', $filename) || false !== strpos($filename, '%'))) {
|
||||
$encoding = mb_detect_encoding($filename, null, true);
|
||||
|
||||
for ($i = 0; $i < mb_strlen($filename, $encoding); ++$i) {
|
||||
for ($i = 0, $filenameLength = mb_strlen($filename, $encoding); $i < $filenameLength; ++$i) {
|
||||
$char = mb_substr($filename, $i, 1, $encoding);
|
||||
|
||||
if ('%' === $char || ord($char) < 32 || ord($char) > 126) {
|
||||
|
|
138
web/vendor/symfony/http-foundation/Request.php
vendored
138
web/vendor/symfony/http-foundation/Request.php
vendored
|
@ -206,6 +206,15 @@ class Request
|
|||
|
||||
protected static $requestFactory;
|
||||
|
||||
private $isForwardedValid = true;
|
||||
|
||||
private static $forwardedParams = array(
|
||||
self::HEADER_CLIENT_IP => 'for',
|
||||
self::HEADER_CLIENT_HOST => 'host',
|
||||
self::HEADER_CLIENT_PROTO => 'proto',
|
||||
self::HEADER_CLIENT_PORT => 'host',
|
||||
);
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -596,6 +605,7 @@ class Request
|
|||
* * Request::HEADER_CLIENT_HOST: defaults to X-Forwarded-Host (see getHost())
|
||||
* * Request::HEADER_CLIENT_PORT: defaults to X-Forwarded-Port (see getPort())
|
||||
* * Request::HEADER_CLIENT_PROTO: defaults to X-Forwarded-Proto (see getScheme() and isSecure())
|
||||
* * Request::HEADER_FORWARDED: defaults to Forwarded (see RFC 7239)
|
||||
*
|
||||
* Setting an empty value allows to disable the trusted header for the given key.
|
||||
*
|
||||
|
@ -805,41 +815,13 @@ class Request
|
|||
*/
|
||||
public function getClientIps()
|
||||
{
|
||||
$clientIps = array();
|
||||
$ip = $this->server->get('REMOTE_ADDR');
|
||||
|
||||
if (!$this->isFromTrustedProxy()) {
|
||||
return array($ip);
|
||||
}
|
||||
|
||||
$hasTrustedForwardedHeader = self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED]);
|
||||
$hasTrustedClientIpHeader = self::$trustedHeaders[self::HEADER_CLIENT_IP] && $this->headers->has(self::$trustedHeaders[self::HEADER_CLIENT_IP]);
|
||||
|
||||
if ($hasTrustedForwardedHeader) {
|
||||
$forwardedHeader = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]);
|
||||
preg_match_all('{(for)=("?\[?)([a-z0-9\.:_\-/]*)}', $forwardedHeader, $matches);
|
||||
$forwardedClientIps = $matches[3];
|
||||
|
||||
$forwardedClientIps = $this->normalizeAndFilterClientIps($forwardedClientIps, $ip);
|
||||
$clientIps = $forwardedClientIps;
|
||||
}
|
||||
|
||||
if ($hasTrustedClientIpHeader) {
|
||||
$xForwardedForClientIps = array_map('trim', explode(',', $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_IP])));
|
||||
|
||||
$xForwardedForClientIps = $this->normalizeAndFilterClientIps($xForwardedForClientIps, $ip);
|
||||
$clientIps = $xForwardedForClientIps;
|
||||
}
|
||||
|
||||
if ($hasTrustedForwardedHeader && $hasTrustedClientIpHeader && $forwardedClientIps !== $xForwardedForClientIps) {
|
||||
throw new ConflictingHeadersException('The request has both a trusted Forwarded header and a trusted Client IP header, conflicting with each other with regards to the originating IP addresses of the request. This is the result of a misconfiguration. You should either configure your proxy only to send one of these headers, or configure Symfony to distrust one of them.');
|
||||
}
|
||||
|
||||
if (!$hasTrustedForwardedHeader && !$hasTrustedClientIpHeader) {
|
||||
return $this->normalizeAndFilterClientIps(array(), $ip);
|
||||
}
|
||||
|
||||
return $clientIps;
|
||||
return $this->getTrustedValues(self::HEADER_CLIENT_IP, $ip) ?: array($ip);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -965,31 +947,25 @@ class Request
|
|||
*/
|
||||
public function getPort()
|
||||
{
|
||||
if ($this->isFromTrustedProxy()) {
|
||||
if (self::$trustedHeaders[self::HEADER_CLIENT_PORT] && $port = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PORT])) {
|
||||
return $port;
|
||||
}
|
||||
|
||||
if (self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && 'https' === $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO], 'http')) {
|
||||
return 443;
|
||||
}
|
||||
if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_PORT)) {
|
||||
$host = $host[0];
|
||||
} elseif ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) {
|
||||
$host = $host[0];
|
||||
} elseif (!$host = $this->headers->get('HOST')) {
|
||||
return $this->server->get('SERVER_PORT');
|
||||
}
|
||||
|
||||
if ($host = $this->headers->get('HOST')) {
|
||||
if ($host[0] === '[') {
|
||||
$pos = strpos($host, ':', strrpos($host, ']'));
|
||||
} else {
|
||||
$pos = strrpos($host, ':');
|
||||
}
|
||||
|
||||
if (false !== $pos) {
|
||||
return (int) substr($host, $pos + 1);
|
||||
}
|
||||
|
||||
return 'https' === $this->getScheme() ? 443 : 80;
|
||||
if ($host[0] === '[') {
|
||||
$pos = strpos($host, ':', strrpos($host, ']'));
|
||||
} else {
|
||||
$pos = strrpos($host, ':');
|
||||
}
|
||||
|
||||
return $this->server->get('SERVER_PORT');
|
||||
if (false !== $pos) {
|
||||
return (int) substr($host, $pos + 1);
|
||||
}
|
||||
|
||||
return 'https' === $this->getScheme() ? 443 : 80;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1189,8 +1165,8 @@ class Request
|
|||
*/
|
||||
public function isSecure()
|
||||
{
|
||||
if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_PROTO] && $proto = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_PROTO])) {
|
||||
return in_array(strtolower(current(explode(',', $proto))), array('https', 'on', 'ssl', '1'));
|
||||
if ($this->isFromTrustedProxy() && $proto = $this->getTrustedValues(self::HEADER_CLIENT_PROTO)) {
|
||||
return in_array(strtolower($proto[0]), array('https', 'on', 'ssl', '1'), true);
|
||||
}
|
||||
|
||||
$https = $this->server->get('HTTPS');
|
||||
|
@ -1215,10 +1191,8 @@ class Request
|
|||
*/
|
||||
public function getHost()
|
||||
{
|
||||
if ($this->isFromTrustedProxy() && self::$trustedHeaders[self::HEADER_CLIENT_HOST] && $host = $this->headers->get(self::$trustedHeaders[self::HEADER_CLIENT_HOST])) {
|
||||
$elements = explode(',', $host);
|
||||
|
||||
$host = $elements[count($elements) - 1];
|
||||
if ($this->isFromTrustedProxy() && $host = $this->getTrustedValues(self::HEADER_CLIENT_HOST)) {
|
||||
$host = $host[0];
|
||||
} elseif (!$host = $this->headers->get('HOST')) {
|
||||
if (!$host = $this->server->get('SERVER_NAME')) {
|
||||
$host = $this->server->get('SERVER_ADDR', '');
|
||||
|
@ -1387,10 +1361,10 @@ class Request
|
|||
public function getRequestFormat($default = 'html')
|
||||
{
|
||||
if (null === $this->format) {
|
||||
$this->format = $this->get('_format', $default);
|
||||
$this->format = $this->get('_format');
|
||||
}
|
||||
|
||||
return $this->format;
|
||||
return null === $this->format ? $default : $this->format;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1779,6 +1753,9 @@ class Request
|
|||
|
||||
// Does the baseUrl have anything in common with the request_uri?
|
||||
$requestUri = $this->getRequestUri();
|
||||
if ($requestUri !== '' && $requestUri[0] !== '/') {
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, $baseUrl)) {
|
||||
// full $baseUrl matches
|
||||
|
@ -1851,9 +1828,12 @@ class Request
|
|||
}
|
||||
|
||||
// Remove the query string from REQUEST_URI
|
||||
if ($pos = strpos($requestUri, '?')) {
|
||||
if (false !== $pos = strpos($requestUri, '?')) {
|
||||
$requestUri = substr($requestUri, 0, $pos);
|
||||
}
|
||||
if ($requestUri !== '' && $requestUri[0] !== '/') {
|
||||
$requestUri = '/'.$requestUri;
|
||||
}
|
||||
|
||||
$pathInfo = substr($requestUri, strlen($baseUrl));
|
||||
if (null !== $baseUrl && (false === $pathInfo || '' === $pathInfo)) {
|
||||
|
@ -1947,8 +1927,48 @@ class Request
|
|||
return self::$trustedProxies && IpUtils::checkIp($this->server->get('REMOTE_ADDR'), self::$trustedProxies);
|
||||
}
|
||||
|
||||
private function getTrustedValues($type, $ip = null)
|
||||
{
|
||||
$clientValues = array();
|
||||
$forwardedValues = array();
|
||||
|
||||
if (self::$trustedHeaders[$type] && $this->headers->has(self::$trustedHeaders[$type])) {
|
||||
foreach (explode(',', $this->headers->get(self::$trustedHeaders[$type])) as $v) {
|
||||
$clientValues[] = (self::HEADER_CLIENT_PORT === $type ? '0.0.0.0:' : '').trim($v);
|
||||
}
|
||||
}
|
||||
|
||||
if (self::$trustedHeaders[self::HEADER_FORWARDED] && $this->headers->has(self::$trustedHeaders[self::HEADER_FORWARDED])) {
|
||||
$forwardedValues = $this->headers->get(self::$trustedHeaders[self::HEADER_FORWARDED]);
|
||||
$forwardedValues = preg_match_all(sprintf('{(?:%s)=(?:"?\[?)([a-zA-Z0-9\.:_\-/]*+)}', self::$forwardedParams[$type]), $forwardedValues, $matches) ? $matches[1] : array();
|
||||
}
|
||||
|
||||
if (null !== $ip) {
|
||||
$clientValues = $this->normalizeAndFilterClientIps($clientValues, $ip);
|
||||
$forwardedValues = $this->normalizeAndFilterClientIps($forwardedValues, $ip);
|
||||
}
|
||||
|
||||
if ($forwardedValues === $clientValues || !$clientValues) {
|
||||
return $forwardedValues;
|
||||
}
|
||||
|
||||
if (!$forwardedValues) {
|
||||
return $clientValues;
|
||||
}
|
||||
|
||||
if (!$this->isForwardedValid) {
|
||||
return null !== $ip ? array('0.0.0.0', $ip) : array();
|
||||
}
|
||||
$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]));
|
||||
}
|
||||
|
||||
private function normalizeAndFilterClientIps(array $clientIps, $ip)
|
||||
{
|
||||
if (!$clientIps) {
|
||||
return array();
|
||||
}
|
||||
$clientIps[] = $ip; // Complete the IP chain with the IP the request actually came from
|
||||
$firstTrustedIp = null;
|
||||
|
||||
|
|
11
web/vendor/symfony/http-foundation/Response.php
vendored
11
web/vendor/symfony/http-foundation/Response.php
vendored
|
@ -201,6 +201,11 @@ class Response
|
|||
$this->setContent($content);
|
||||
$this->setStatusCode($status);
|
||||
$this->setProtocolVersion('1.0');
|
||||
|
||||
/* RFC2616 - 14.18 says all Responses need to have a Date */
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(new \DateTime(null, new \DateTimeZone('UTC')));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,6 +334,7 @@ class Response
|
|||
return $this;
|
||||
}
|
||||
|
||||
/* RFC2616 - 14.18 says all Responses need to have a Date */
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(\DateTime::createFromFormat('U', time()));
|
||||
}
|
||||
|
@ -612,6 +618,11 @@ class Response
|
|||
*/
|
||||
public function getDate()
|
||||
{
|
||||
/*
|
||||
RFC2616 - 14.18 says all Responses need to have a Date.
|
||||
Make sure we provide one even if it the header
|
||||
has been removed in the meantime.
|
||||
*/
|
||||
if (!$this->headers->has('Date')) {
|
||||
$this->setDate(\DateTime::createFromFormat('U', time()));
|
||||
}
|
||||
|
|
|
@ -58,9 +58,9 @@ class MockArraySessionStorage implements SessionStorageInterface
|
|||
protected $metadataBag;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
* @var array|SessionBagInterface[]
|
||||
*/
|
||||
protected $bags;
|
||||
protected $bags = array();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
|
Reference in a new issue