mirror of
https://gitlab.com/TheGamecraft/c-cms.git
synced 2026-04-23 11:29:10 -04:00
ALPHA 3.0.2a
This commit is contained in:
92
vendor/symfony/http-foundation/Request.php
vendored
92
vendor/symfony/http-foundation/Request.php
vendored
@@ -281,7 +281,7 @@ class Request
|
||||
$request = self::createRequestFromFactory($_GET, $_POST, array(), $_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'))
|
||||
&& \in_array(strtoupper($request->server->get('REQUEST_METHOD', 'GET')), array('PUT', 'DELETE', 'PATCH'))
|
||||
) {
|
||||
parse_str($request->getContent(), $data);
|
||||
$request->request = new ParameterBag($data);
|
||||
@@ -533,7 +533,7 @@ 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, array('CONTENT_TYPE', 'CONTENT_LENGTH'))) {
|
||||
$_SERVER[$key] = implode(', ', $value);
|
||||
} else {
|
||||
$_SERVER['HTTP_'.$key] = implode(', ', $value);
|
||||
@@ -1072,7 +1072,7 @@ class Request
|
||||
}
|
||||
|
||||
$targetDirs[] = $targetFile;
|
||||
$path = str_repeat('../', count($sourceDirs)).implode('/', $targetDirs);
|
||||
$path = str_repeat('../', \count($sourceDirs)).implode('/', $targetDirs);
|
||||
|
||||
// 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
|
||||
@@ -1111,7 +1111,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]), array('https', 'on', 'ssl', '1'), true);
|
||||
}
|
||||
|
||||
$https = $this->server->get('HTTPS');
|
||||
@@ -1157,10 +1157,10 @@ class Request
|
||||
throw new SuspiciousOperationException(sprintf('Invalid Host "%s".', $host));
|
||||
}
|
||||
|
||||
if (count(self::$trustedHostPatterns) > 0) {
|
||||
if (\count(self::$trustedHostPatterns) > 0) {
|
||||
// to avoid host header injection attacks, you should provide a list of trusted host patterns
|
||||
|
||||
if (in_array($host, self::$trustedHosts)) {
|
||||
if (\in_array($host, self::$trustedHosts)) {
|
||||
return $host;
|
||||
}
|
||||
|
||||
@@ -1218,7 +1218,10 @@ class Request
|
||||
if ($method = $this->headers->get('X-HTTP-METHOD-OVERRIDE')) {
|
||||
$this->method = strtoupper($method);
|
||||
} elseif (self::$httpMethodParameterOverride) {
|
||||
$this->method = strtoupper($this->request->get('_method', $this->query->get('_method', 'POST')));
|
||||
$method = $this->request->get('_method', $this->query->get('_method', 'POST'));
|
||||
if (\is_string($method)) {
|
||||
$this->method = strtoupper($method);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1289,10 +1292,10 @@ class Request
|
||||
}
|
||||
|
||||
foreach (static::$formats as $format => $mimeTypes) {
|
||||
if (in_array($mimeType, (array) $mimeTypes)) {
|
||||
if (\in_array($mimeType, (array) $mimeTypes)) {
|
||||
return $format;
|
||||
}
|
||||
if (null !== $canonicalMimeType && in_array($canonicalMimeType, (array) $mimeTypes)) {
|
||||
if (null !== $canonicalMimeType && \in_array($canonicalMimeType, (array) $mimeTypes)) {
|
||||
return $format;
|
||||
}
|
||||
}
|
||||
@@ -1310,7 +1313,7 @@ class Request
|
||||
static::initializeFormats();
|
||||
}
|
||||
|
||||
static::$formats[$format] = is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);
|
||||
static::$formats[$format] = \is_array($mimeTypes) ? $mimeTypes : array($mimeTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1422,12 +1425,12 @@ class Request
|
||||
*/
|
||||
public function isMethodSafe(/* $andCacheable = true */)
|
||||
{
|
||||
if (!func_num_args() || func_get_arg(0)) {
|
||||
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.');
|
||||
}
|
||||
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD', 'OPTIONS', 'TRACE'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1437,7 +1440,7 @@ class Request
|
||||
*/
|
||||
public function isMethodIdempotent()
|
||||
{
|
||||
return in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
|
||||
return \in_array($this->getMethod(), array('HEAD', 'GET', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'PURGE'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1449,7 +1452,7 @@ class Request
|
||||
*/
|
||||
public function isMethodCacheable()
|
||||
{
|
||||
return in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
return \in_array($this->getMethod(), array('GET', 'HEAD'));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1487,7 +1490,7 @@ class Request
|
||||
*/
|
||||
public function getContent($asResource = false)
|
||||
{
|
||||
$currentContentIsResource = is_resource($this->content);
|
||||
$currentContentIsResource = \is_resource($this->content);
|
||||
|
||||
if (true === $asResource) {
|
||||
if ($currentContentIsResource) {
|
||||
@@ -1497,7 +1500,7 @@ class Request
|
||||
}
|
||||
|
||||
// Content passed in parameter (test)
|
||||
if (is_string($this->content)) {
|
||||
if (\is_string($this->content)) {
|
||||
$resource = fopen('php://temp', 'r+');
|
||||
fwrite($resource, $this->content);
|
||||
rewind($resource);
|
||||
@@ -1565,7 +1568,7 @@ class Request
|
||||
$extendedPreferredLanguages[] = $language;
|
||||
if (false !== $position = strpos($language, '_')) {
|
||||
$superLanguage = substr($language, 0, $position);
|
||||
if (!in_array($superLanguage, $preferredLanguages)) {
|
||||
if (!\in_array($superLanguage, $preferredLanguages)) {
|
||||
$extendedPreferredLanguages[] = $superLanguage;
|
||||
}
|
||||
}
|
||||
@@ -1596,11 +1599,11 @@ class Request
|
||||
// Language not listed in ISO 639 that are not variants
|
||||
// of any listed language, which can be registered with the
|
||||
// i-prefix, such as i-cherokee
|
||||
if (count($codes) > 1) {
|
||||
if (\count($codes) > 1) {
|
||||
$lang = $codes[1];
|
||||
}
|
||||
} else {
|
||||
for ($i = 0, $max = count($codes); $i < $max; ++$i) {
|
||||
for ($i = 0, $max = \count($codes); $i < $max; ++$i) {
|
||||
if (0 === $i) {
|
||||
$lang = strtolower($codes[0]);
|
||||
} else {
|
||||
@@ -1685,18 +1688,7 @@ class Request
|
||||
{
|
||||
$requestUri = '';
|
||||
|
||||
if ($this->headers->has('X_ORIGINAL_URL')) {
|
||||
// IIS with Microsoft Rewrite Module
|
||||
$requestUri = $this->headers->get('X_ORIGINAL_URL');
|
||||
$this->headers->remove('X_ORIGINAL_URL');
|
||||
$this->server->remove('HTTP_X_ORIGINAL_URL');
|
||||
$this->server->remove('UNENCODED_URL');
|
||||
$this->server->remove('IIS_WasUrlRewritten');
|
||||
} elseif ($this->headers->has('X_REWRITE_URL')) {
|
||||
// IIS with ISAPI_Rewrite
|
||||
$requestUri = $this->headers->get('X_REWRITE_URL');
|
||||
$this->headers->remove('X_REWRITE_URL');
|
||||
} elseif ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $this->server->get('UNENCODED_URL')) {
|
||||
if ('1' == $this->server->get('IIS_WasUrlRewritten') && '' != $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');
|
||||
@@ -1706,7 +1698,7 @@ class Request
|
||||
// HTTP proxy reqs setup request URI with scheme and host [and port] + the URL path, only use URL path
|
||||
$schemeAndHttpHost = $this->getSchemeAndHttpHost();
|
||||
if (0 === strpos($requestUri, $schemeAndHttpHost)) {
|
||||
$requestUri = substr($requestUri, strlen($schemeAndHttpHost));
|
||||
$requestUri = substr($requestUri, \strlen($schemeAndHttpHost));
|
||||
}
|
||||
} elseif ($this->server->has('ORIG_PATH_INFO')) {
|
||||
// IIS 5.0, PHP as CGI
|
||||
@@ -1746,7 +1738,7 @@ class Request
|
||||
$segs = explode('/', trim($file, '/'));
|
||||
$segs = array_reverse($segs);
|
||||
$index = 0;
|
||||
$last = count($segs);
|
||||
$last = \count($segs);
|
||||
$baseUrl = '';
|
||||
do {
|
||||
$seg = $segs[$index];
|
||||
@@ -1766,9 +1758,9 @@ class Request
|
||||
return $prefix;
|
||||
}
|
||||
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(dirname($baseUrl), '/'.DIRECTORY_SEPARATOR).'/')) {
|
||||
if ($baseUrl && false !== $prefix = $this->getUrlencodedPrefix($requestUri, rtrim(\dirname($baseUrl), '/'.\DIRECTORY_SEPARATOR).'/')) {
|
||||
// directory portion of $baseUrl matches
|
||||
return rtrim($prefix, '/'.DIRECTORY_SEPARATOR);
|
||||
return rtrim($prefix, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
$truncatedRequestUri = $requestUri;
|
||||
@@ -1785,11 +1777,11 @@ class Request
|
||||
// If using mod_rewrite or ISAPI_Rewrite strip the script filename
|
||||
// out of baseUrl. $pos !== 0 makes sure it is not matching a value
|
||||
// from PATH_INFO or QUERY_STRING
|
||||
if (strlen($requestUri) >= strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
|
||||
$baseUrl = substr($requestUri, 0, $pos + strlen($baseUrl));
|
||||
if (\strlen($requestUri) >= \strlen($baseUrl) && (false !== $pos = strpos($requestUri, $baseUrl)) && 0 !== $pos) {
|
||||
$baseUrl = substr($requestUri, 0, $pos + \strlen($baseUrl));
|
||||
}
|
||||
|
||||
return rtrim($baseUrl, '/'.DIRECTORY_SEPARATOR);
|
||||
return rtrim($baseUrl, '/'.\DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1806,12 +1798,12 @@ class Request
|
||||
|
||||
$filename = basename($this->server->get('SCRIPT_FILENAME'));
|
||||
if (basename($baseUrl) === $filename) {
|
||||
$basePath = dirname($baseUrl);
|
||||
$basePath = \dirname($baseUrl);
|
||||
} else {
|
||||
$basePath = $baseUrl;
|
||||
}
|
||||
|
||||
if ('\\' === DIRECTORY_SEPARATOR) {
|
||||
if ('\\' === \DIRECTORY_SEPARATOR) {
|
||||
$basePath = str_replace('\\', '/', $basePath);
|
||||
}
|
||||
|
||||
@@ -1841,7 +1833,7 @@ class Request
|
||||
return $requestUri;
|
||||
}
|
||||
|
||||
$pathInfo = substr($requestUri, strlen($baseUrl));
|
||||
$pathInfo = substr($requestUri, \strlen($baseUrl));
|
||||
if (false === $pathInfo || '' === $pathInfo) {
|
||||
// If substr() returns false then PATH_INFO is set to an empty string
|
||||
return '/';
|
||||
@@ -1895,7 +1887,7 @@ class Request
|
||||
return false;
|
||||
}
|
||||
|
||||
$len = strlen($prefix);
|
||||
$len = \strlen($prefix);
|
||||
|
||||
if (preg_match(sprintf('#^(%%[[:xdigit:]]{2}|.){%d}#', $len), $string, $match)) {
|
||||
return $match[0];
|
||||
@@ -1907,7 +1899,7 @@ class Request
|
||||
private static function createRequestFromFactory(array $query = array(), array $request = array(), array $attributes = array(), array $cookies = array(), array $files = array(), array $server = array(), $content = null)
|
||||
{
|
||||
if (self::$requestFactory) {
|
||||
$request = call_user_func(self::$requestFactory, $query, $request, $attributes, $cookies, $files, $server, $content);
|
||||
$request = \call_user_func(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.');
|
||||
@@ -1949,10 +1941,16 @@ class Request
|
||||
$forwardedValues = array();
|
||||
$param = self::$forwardedParams[$type];
|
||||
foreach ($parts as $subParts) {
|
||||
$assoc = HeaderUtils::combine($subParts);
|
||||
if (isset($assoc[$param])) {
|
||||
$forwardedValues[] = $assoc[$param];
|
||||
if (null === $v = HeaderUtils::combine($subParts)[$param] ?? null) {
|
||||
continue;
|
||||
}
|
||||
if (self::HEADER_X_FORWARDED_PORT === $type) {
|
||||
if (']' === substr($v, -1) || false === $v = strrchr($v, ':')) {
|
||||
$v = $this->isSecure() ? ':443' : ':80';
|
||||
}
|
||||
$v = '0.0.0.0'.$v;
|
||||
}
|
||||
$forwardedValues[] = $v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1993,7 +1991,7 @@ class Request
|
||||
if ($i) {
|
||||
$clientIps[$key] = $clientIp = substr($clientIp, 0, $i);
|
||||
}
|
||||
} elseif ('[' == $clientIp[0]) {
|
||||
} elseif (0 === strpos($clientIp, '[')) {
|
||||
// Strip brackets and :port from IPv6 addresses.
|
||||
$i = strpos($clientIp, ']', 1);
|
||||
$clientIps[$key] = $clientIp = substr($clientIp, 1, $i - 1);
|
||||
|
||||
Reference in New Issue
Block a user