From: Tim Düsterhus Date: Wed, 29 Jun 2022 14:17:09 +0000 (+0200) Subject: Update composer dependencies X-Git-Tag: 6.0.0_Alpha_1~1136 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d9d8309d52f1af805028f9841188f49d454d49b8;p=GitHub%2FWoltLab%2FWCF.git Update composer dependencies This fixes a Diactoros regression in e707bb4c8f19bd627f06738e64e5c823f88dc4f7. --- diff --git a/wcfsetup/install/files/lib/system/api/composer.lock b/wcfsetup/install/files/lib/system/api/composer.lock index 8273a2fab0..fcf5bc7995 100644 --- a/wcfsetup/install/files/lib/system/api/composer.lock +++ b/wcfsetup/install/files/lib/system/api/composer.lock @@ -479,16 +479,16 @@ }, { "name": "laminas/laminas-diactoros", - "version": "2.11.1", + "version": "2.11.2", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "25b11d422c2e5dad868f68619888763b30f91e2d" + "reference": "78846cbce0550ec174508a646f46fd6dee76099b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/25b11d422c2e5dad868f68619888763b30f91e2d", - "reference": "25b11d422c2e5dad868f68619888763b30f91e2d", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/78846cbce0550ec174508a646f46fd6dee76099b", + "reference": "78846cbce0550ec174508a646f46fd6dee76099b", "shasum": "" }, "require": { @@ -574,7 +574,7 @@ "type": "community_bridge" } ], - "time": "2022-06-28T21:07:29+00:00" + "time": "2022-06-29T14:15:02+00:00" }, { "name": "laminas/laminas-httphandlerrunner", diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.json b/wcfsetup/install/files/lib/system/api/composer/installed.json index bd2d62d2ea..a03c5de777 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.json +++ b/wcfsetup/install/files/lib/system/api/composer/installed.json @@ -491,17 +491,17 @@ }, { "name": "laminas/laminas-diactoros", - "version": "2.11.1", - "version_normalized": "2.11.1.0", + "version": "2.11.2", + "version_normalized": "2.11.2.0", "source": { "type": "git", "url": "https://github.com/laminas/laminas-diactoros.git", - "reference": "25b11d422c2e5dad868f68619888763b30f91e2d" + "reference": "78846cbce0550ec174508a646f46fd6dee76099b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/25b11d422c2e5dad868f68619888763b30f91e2d", - "reference": "25b11d422c2e5dad868f68619888763b30f91e2d", + "url": "https://api.github.com/repos/laminas/laminas-diactoros/zipball/78846cbce0550ec174508a646f46fd6dee76099b", + "reference": "78846cbce0550ec174508a646f46fd6dee76099b", "shasum": "" }, "require": { @@ -530,7 +530,7 @@ "psalm/plugin-phpunit": "^0.14.0", "vimeo/psalm": "^4.3" }, - "time": "2022-06-28T21:07:29+00:00", + "time": "2022-06-29T14:15:02+00:00", "type": "library", "extra": { "laminas": { diff --git a/wcfsetup/install/files/lib/system/api/composer/installed.php b/wcfsetup/install/files/lib/system/api/composer/installed.php index 94088a9b6f..b02b1598af 100644 --- a/wcfsetup/install/files/lib/system/api/composer/installed.php +++ b/wcfsetup/install/files/lib/system/api/composer/installed.php @@ -74,9 +74,9 @@ 'dev_requirement' => false, ), 'laminas/laminas-diactoros' => array( - 'pretty_version' => '2.11.1', - 'version' => '2.11.1.0', - 'reference' => '25b11d422c2e5dad868f68619888763b30f91e2d', + 'pretty_version' => '2.11.2', + 'version' => '2.11.2.0', + 'reference' => '78846cbce0550ec174508a646f46fd6dee76099b', 'type' => 'library', 'install_path' => __DIR__ . '/../laminas/laminas-diactoros', 'aliases' => array(), diff --git a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/psalm-baseline.xml b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/psalm-baseline.xml index 21ba727135..1456fb1248 100644 --- a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/psalm-baseline.xml +++ b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/psalm-baseline.xml @@ -243,9 +243,13 @@ - + $headers['cookie'] + $host + + $headers + $iisUrlRewritten $requestUri @@ -257,6 +261,9 @@ $defaults + + self::marshalHostAndPortFromHeader($host) + ServerRequest diff --git a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFactory.php b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFactory.php index 8b9d5fda11..30eb71cbe0 100644 --- a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFactory.php +++ b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFactory.php @@ -75,7 +75,7 @@ class ServerRequestFactory implements ServerRequestFactoryInterface return $requestFilter(new ServerRequest( $server, $files, - self::marshalUriFromSapi($server), + self::marshalUriFromSapi($server, $headers), marshalMethodFromSapi($server), 'php://input', $headers, @@ -105,9 +105,10 @@ class ServerRequestFactory implements ServerRequestFactoryInterface /** * Marshal a Uri instance based on the values present in the $_SERVER array and headers. * + * @param array> $headers * @param array $server SAPI parameters */ - private static function marshalUriFromSapi(array $server) : Uri + private static function marshalUriFromSapi(array $server, array $headers) : Uri { $uri = new Uri(''); @@ -122,7 +123,7 @@ class ServerRequestFactory implements ServerRequestFactoryInterface $uri = $uri->withScheme($https ? 'https' : 'http'); // Set the host - [$host, $port] = self::marshalHostAndPort($server); + [$host, $port] = self::marshalHostAndPort($server, $headers); if (! empty($host)) { $uri = $uri->withHost($host); if (! empty($port)) { @@ -157,13 +158,19 @@ class ServerRequestFactory implements ServerRequestFactoryInterface /** * Marshal the host and port from the PHP environment. * + * @param array> $headers * @return array{string, int|null} Array of two items, host and port, * in that order (can be passed to a list() operation). */ - private static function marshalHostAndPort(array $server) : array + private static function marshalHostAndPort(array $server, array $headers) : array { static $defaults = ['', null]; + $host = self::getHeaderFromArray('host', $headers, false); + if ($host !== false) { + return self::marshalHostAndPortFromHeader($host); + } + if (! isset($server['SERVER_NAME'])) { return $defaults; } @@ -256,4 +263,48 @@ class ServerRequestFactory implements ServerRequestFactoryInterface return 'on' === strtolower($https); } + + /** + * @param string|list $host + * @return array Array of two items, host and port, in that order (can be + * passed to a list() operation). + */ + private static function marshalHostAndPortFromHeader($host): array + { + if (is_array($host)) { + $host = implode(', ', $host); + } + + $port = null; + + // works for regname, IPv4 & IPv6 + if (preg_match('|\:(\d+)$|', $host, $matches)) { + $host = substr($host, 0, -1 * (strlen($matches[1]) + 1)); + $port = (int) $matches[1]; + } + + return [$host, $port]; + } + + /** + * Retrieve a header value from an array of headers using a case-insensitive lookup. + * + * @param array> $headers Key/value header pairs + * @param mixed $default Default value to return if header not found + * @return mixed + */ + private static function getHeaderFromArray(string $name, array $headers, $default = null) + { + $header = strtolower($name); + $headers = array_change_key_case($headers, CASE_LOWER); + if (! array_key_exists($header, $headers)) { + return $default; + } + + if (is_string($headers[$header])) { + return $headers[$header]; + } + + return implode(', ', $headers[$header]); + } } diff --git a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFilter/FilterUsingXForwardedHeaders.php b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFilter/FilterUsingXForwardedHeaders.php index fcac3753ea..00b9707b45 100644 --- a/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFilter/FilterUsingXForwardedHeaders.php +++ b/wcfsetup/install/files/lib/system/api/laminas/laminas-diactoros/src/ServerRequestFilter/FilterUsingXForwardedHeaders.php @@ -83,7 +83,8 @@ final class FilterUsingXForwardedHeaders implements FilterServerRequestInterface $uri = $uri->withPort((int) $header); break; case self::HEADER_PROTO: - $uri = $uri->withScheme($header); + $scheme = strtolower($header) === 'https' ? 'https' : 'http'; + $uri = $uri->withScheme($scheme); break; } }