From 91d8cd2c873be4dfebc3fb84d41d840f8a47fe82 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Thu, 26 Jan 2023 00:00:55 -0500 Subject: [PATCH] Prevent fatal error when probing WebFinger address in Network\Probe::feed --- src/Network/Probe.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Network/Probe.php b/src/Network/Probe.php index d35490d0d3..7c2760393a 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -761,7 +761,7 @@ class Probe $result = self::feed($uri); } else { // We overwrite the detected nick with our try if the previois routines hadn't detected it. - // Additionally it is overwritten when the nickname doesn't make sense (contains spaces). + // Additionally, it is overwritten when the nickname doesn't make sense (contains spaces). if ((empty($result['nick']) || (strstr($result['nick'], ' '))) && ($nick != '')) { $result['nick'] = $nick; } @@ -1853,11 +1853,18 @@ class Probe */ private static function feed(string $url, bool $probe = true): array { - $curlResult = DI::httpClient()->get($url, HttpClientAccept::FEED_XML); + try { + $curlResult = DI::httpClient()->get($url, HttpClientAccept::FEED_XML); + } catch(\Throwable $e) { + DI::logger()->info('Error requesting feed URL', ['url' => $url, 'exception' => $e]); + return []; + } + if ($curlResult->isTimeout()) { self::$isTimeout = true; return []; } + $feed = $curlResult->getBody(); $feed_data = Feed::import($feed); -- 2.39.5