From: Alexander Ebert Date: Fri, 30 Aug 2024 15:42:34 +0000 (+0200) Subject: Fix the handling of HTTP headers X-Git-Tag: 6.1.0_Beta_1^0 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=7a1be0cbcc77c84e77d9da5d88da9192780e4196;p=GitHub%2FWoltLab%2FWCF.git Fix the handling of HTTP headers --- diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 74430820c5..4f798ee551 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -211,8 +211,8 @@ final class PackageUpdateDispatcher extends SingletonFactory ]; // check if server indicates support for a newer API - if ($updateServer->apiVersion !== '3.1' && !empty($response->getHeader('wcf-update-server-api'))) { - $apiVersions = \explode(' ', \reset($response->getHeader('wcf-update-server-api'))); + if ($updateServer->apiVersion !== '3.1' && $response->getHeader('wcf-update-server-api') !== []) { + $apiVersions = \explode(' ', $response->getHeader('wcf-update-server-api')[0]); if (\in_array('3.1', $apiVersions)) { $apiVersion = $data['apiVersion'] = '3.1'; } elseif (\in_array('2.1', $apiVersions)) { @@ -228,16 +228,16 @@ final class PackageUpdateDispatcher extends SingletonFactory $metaData = []; if (\in_array($apiVersion, ['2.1', '3.1'])) { - if (empty($response->getHeader('etag')) && empty($response->getHeader('last-modified'))) { + if ($response->getHeader('etag') === [] && $response->getHeader('last-modified') === []) { throw new SystemException("Missing required HTTP headers 'etag' and 'last-modified'."); } $metaData['list'] = []; - if (!empty($response->getHeader('etag'))) { - $metaData['list']['etag'] = \reset($response->getHeader('etag')); + if ($response->getHeader('etag') !== []) { + $metaData['list']['etag'] = $response->getHeader('etag')[0]; } - if (!empty($response->getHeader('last-modified'))) { - $metaData['list']['lastModified'] = \reset($response->getHeader('last-modified')); + if ($response->getHeader('last-modified') !== []) { + $metaData['list']['lastModified'] = $response->getHeader('last-modified')[0]; } } $data['metaData'] = \serialize($metaData);