mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°6002 - Explicitly add symfony/http-foundation and symfony/http-kernel to composer.json for easier lib update
This commit is contained in:
@@ -206,15 +206,19 @@ class BinaryFileResponse extends Response
|
||||
*/
|
||||
public function prepare(Request $request)
|
||||
{
|
||||
if ($this->isInformational() || $this->isEmpty()) {
|
||||
parent::prepare($request);
|
||||
|
||||
$this->maxlen = 0;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
if (!$this->headers->has('Content-Type')) {
|
||||
$this->headers->set('Content-Type', $this->file->getMimeType() ?: 'application/octet-stream');
|
||||
}
|
||||
|
||||
if ('HTTP/1.0' !== $request->server->get('SERVER_PROTOCOL')) {
|
||||
$this->setProtocolVersion('1.1');
|
||||
}
|
||||
|
||||
$this->ensureIEOverSSLCompatibility($request);
|
||||
parent::prepare($request);
|
||||
|
||||
$this->offset = 0;
|
||||
$this->maxlen = -1;
|
||||
@@ -222,6 +226,7 @@ class BinaryFileResponse extends Response
|
||||
if (false === $fileSize = $this->file->getSize()) {
|
||||
return $this;
|
||||
}
|
||||
$this->headers->remove('Transfer-Encoding');
|
||||
$this->headers->set('Content-Length', $fileSize);
|
||||
|
||||
if (!$this->headers->has('Accept-Ranges')) {
|
||||
@@ -291,6 +296,10 @@ class BinaryFileResponse extends Response
|
||||
}
|
||||
}
|
||||
|
||||
if ($request->isMethod('HEAD')) {
|
||||
$this->maxlen = 0;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -312,40 +321,42 @@ class BinaryFileResponse extends Response
|
||||
*/
|
||||
public function sendContent()
|
||||
{
|
||||
if (!$this->isSuccessful()) {
|
||||
return parent::sendContent();
|
||||
}
|
||||
|
||||
if (0 === $this->maxlen) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
$out = fopen('php://output', 'w');
|
||||
$file = fopen($this->file->getPathname(), 'r');
|
||||
|
||||
ignore_user_abort(true);
|
||||
|
||||
if (0 !== $this->offset) {
|
||||
fseek($file, $this->offset);
|
||||
}
|
||||
|
||||
$length = $this->maxlen;
|
||||
while ($length && !feof($file)) {
|
||||
$read = ($length > $this->chunkSize) ? $this->chunkSize : $length;
|
||||
$length -= $read;
|
||||
|
||||
stream_copy_to_stream($file, $out, $read);
|
||||
|
||||
if (connection_aborted()) {
|
||||
break;
|
||||
try {
|
||||
if (!$this->isSuccessful()) {
|
||||
return parent::sendContent();
|
||||
}
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
fclose($file);
|
||||
if (0 === $this->maxlen) {
|
||||
return $this;
|
||||
}
|
||||
|
||||
if ($this->deleteFileAfterSend && is_file($this->file->getPathname())) {
|
||||
unlink($this->file->getPathname());
|
||||
$out = fopen('php://output', 'w');
|
||||
$file = fopen($this->file->getPathname(), 'r');
|
||||
|
||||
ignore_user_abort(true);
|
||||
|
||||
if (0 !== $this->offset) {
|
||||
fseek($file, $this->offset);
|
||||
}
|
||||
|
||||
$length = $this->maxlen;
|
||||
while ($length && !feof($file)) {
|
||||
$read = ($length > $this->chunkSize) ? $this->chunkSize : $length;
|
||||
$length -= $read;
|
||||
|
||||
stream_copy_to_stream($file, $out, $read);
|
||||
|
||||
if (connection_aborted()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
fclose($file);
|
||||
} finally {
|
||||
if ($this->deleteFileAfterSend && is_file($this->file->getPathname())) {
|
||||
unlink($this->file->getPathname());
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
namespace Symfony\Component\HttpFoundation\Exception;
|
||||
|
||||
/**
|
||||
* Raised when a session does not exists. This happens in the following cases:
|
||||
* Raised when a session does not exist. This happens in the following cases:
|
||||
* - the session is not enabled
|
||||
* - attempt to read a session outside a request context (ie. cli script).
|
||||
*
|
||||
|
||||
@@ -86,7 +86,7 @@ class IpUtils
|
||||
[$address, $netmask] = explode('/', $ip, 2);
|
||||
|
||||
if ('0' === $netmask) {
|
||||
return self::$checkedIps[$cacheKey] = filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
|
||||
return self::$checkedIps[$cacheKey] = false !== filter_var($address, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV4);
|
||||
}
|
||||
|
||||
if ($netmask < 0 || $netmask > 32) {
|
||||
@@ -135,9 +135,18 @@ class IpUtils
|
||||
throw new \RuntimeException('Unable to check Ipv6. Check that PHP was not compiled with option "disable-ipv6".');
|
||||
}
|
||||
|
||||
// Check to see if we were given a IP4 $requestIp or $ip by mistake
|
||||
if (!filter_var($requestIp, \FILTER_VALIDATE_IP, \FILTER_FLAG_IPV6)) {
|
||||
return self::$checkedIps[$cacheKey] = false;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
@@ -146,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;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2004-2022 Fabien Potencier
|
||||
Copyright (c) 2004-2023 Fabien Potencier
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -35,9 +35,7 @@ abstract class AbstractRequestRateLimiter implements RequestRateLimiterInterface
|
||||
foreach ($limiters as $limiter) {
|
||||
$rateLimit = $limiter->consume(1);
|
||||
|
||||
if (null === $minimalRateLimit || $rateLimit->getRemainingTokens() < $minimalRateLimit->getRemainingTokens()) {
|
||||
$minimalRateLimit = $rateLimit;
|
||||
}
|
||||
$minimalRateLimit = $minimalRateLimit ? self::getMinimalRateLimit($minimalRateLimit, $rateLimit) : $rateLimit;
|
||||
}
|
||||
|
||||
return $minimalRateLimit;
|
||||
@@ -54,4 +52,20 @@ abstract class AbstractRequestRateLimiter implements RequestRateLimiterInterface
|
||||
* @return LimiterInterface[] a set of limiters using keys extracted from the request
|
||||
*/
|
||||
abstract protected function getLimiters(Request $request): array;
|
||||
|
||||
private static function getMinimalRateLimit(RateLimit $first, RateLimit $second): RateLimit
|
||||
{
|
||||
if ($first->isAccepted() !== $second->isAccepted()) {
|
||||
return $first->isAccepted() ? $second : $first;
|
||||
}
|
||||
|
||||
$firstRemainingTokens = $first->getRemainingTokens();
|
||||
$secondRemainingTokens = $second->getRemainingTokens();
|
||||
|
||||
if ($firstRemainingTokens === $secondRemainingTokens) {
|
||||
return $first->getRetryAfter() < $second->getRetryAfter() ? $second : $first;
|
||||
}
|
||||
|
||||
return $firstRemainingTokens > $secondRemainingTokens ? $second : $first;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -522,10 +522,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";
|
||||
}
|
||||
|
||||
@@ -1689,7 +1689,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 +1728,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 +1742,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 +1756,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -399,6 +399,7 @@ class Response
|
||||
litespeed_finish_request();
|
||||
} elseif (!\in_array(\PHP_SAPI, ['cli', 'phpdbg'], true)) {
|
||||
static::closeOutputBuffers(0, true);
|
||||
flush();
|
||||
}
|
||||
|
||||
return $this;
|
||||
@@ -1245,7 +1246,6 @@ class Response
|
||||
while ($level-- > $targetLevel && ($s = $status[$level]) && (!isset($s['del']) ? !isset($s['flags']) || ($s['flags'] & $flags) === $flags : $s['del'])) {
|
||||
if ($flush) {
|
||||
ob_end_flush();
|
||||
flush();
|
||||
} else {
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
#[\ReturnTypeWillChange]
|
||||
public function updateTimestamp($sessionId, $data)
|
||||
{
|
||||
$this->memcached->touch($this->prefix.$sessionId, time() + (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')));
|
||||
$this->memcached->touch($this->prefix.$sessionId, $this->getCompatibleTtl());
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -87,7 +87,20 @@ class MemcachedSessionHandler extends AbstractSessionHandler
|
||||
*/
|
||||
protected function doWrite(string $sessionId, string $data)
|
||||
{
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, time() + (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime')));
|
||||
return $this->memcached->set($this->prefix.$sessionId, $data, $this->getCompatibleTtl());
|
||||
}
|
||||
|
||||
private function getCompatibleTtl(): int
|
||||
{
|
||||
$ttl = (int) ($this->ttl ?? \ini_get('session.gc_maxlifetime'));
|
||||
|
||||
// If the relative TTL that is used exceeds 30 days, memcached will treat the value as Unix time.
|
||||
// We have to convert it to an absolute Unix time at this point, to make sure the TTL is correct.
|
||||
if ($ttl > 60 * 60 * 24 * 30) {
|
||||
$ttl += time();
|
||||
}
|
||||
|
||||
return $ttl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,6 +30,16 @@ class StrictSessionHandler extends AbstractSessionHandler
|
||||
$this->handler = $handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function isWrapper(): bool
|
||||
{
|
||||
return $this->handler instanceof \SessionHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Session\Storage\Handler\StrictSessionHandler;
|
||||
|
||||
/**
|
||||
* @author Drak <drak@zikula.org>
|
||||
*/
|
||||
@@ -22,7 +24,7 @@ class SessionHandlerProxy extends AbstractProxy implements \SessionHandlerInterf
|
||||
{
|
||||
$this->handler = $handler;
|
||||
$this->wrapper = $handler instanceof \SessionHandler;
|
||||
$this->saveHandlerName = $this->wrapper ? \ini_get('session.save_handler') : 'user';
|
||||
$this->saveHandlerName = $this->wrapper || ($handler instanceof StrictSessionHandler && $handler->isWrapper()) ? \ini_get('session.save_handler') : 'user';
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,8 +24,11 @@
|
||||
"require-dev": {
|
||||
"predis/predis": "~1.0",
|
||||
"symfony/cache": "^4.4|^5.0|^6.0",
|
||||
"symfony/dependency-injection": "^5.4|^6.0",
|
||||
"symfony/http-kernel": "^5.4.12|^6.0.12|^6.1.4",
|
||||
"symfony/mime": "^4.4|^5.0|^6.0",
|
||||
"symfony/expression-language": "^4.4|^5.0|^6.0"
|
||||
"symfony/expression-language": "^4.4|^5.0|^6.0",
|
||||
"symfony/rate-limiter": "^5.2|^6.0"
|
||||
},
|
||||
"suggest" : {
|
||||
"symfony/mime": "To use the file extension guesser"
|
||||
|
||||
Reference in New Issue
Block a user