From 6bc77b6772eb41be30512718f04c0f28e5e0c15a Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Tue, 22 Dec 2020 18:48:21 +0100 Subject: [PATCH] Display a somewhat meaningful message when the package list inaccessible --- .../package/PackageUpdateDispatcher.class.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php index 376a5079bb..742e3e6858 100644 --- a/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php +++ b/wcfsetup/install/files/lib/system/package/PackageUpdateDispatcher.class.php @@ -13,6 +13,7 @@ use wcf\system\SingletonFactory; use wcf\system\WCF; use wcf\util\HTTPRequest; use wcf\util\JSON; +use wcf\util\StringUtil; use wcf\util\XML; /** @@ -79,8 +80,17 @@ class PackageUpdateDispatcher extends SingletonFactory { $errorMessage = $e->getMessage(); } catch (PackageUpdateUnauthorizedException $e) { - $reply = $e->getRequest()->getReply(); - list($errorMessage) = reset($reply['httpHeaders']); + $body = $e->getRequest()->getReply()['body']; + + // Try to find the page . + if (preg_match('~<title>(?<title>.*?)~', $body, $matches)) { + $errorMessage = $matches['title']; + } + else { + $errorMessage = $body; + } + + $errorMessage = mb_substr(StringUtil::trim(strip_tags($errorMessage)), 0, 65000); } if ($errorMessage) { -- 2.20.1