]> git.mxchange.org Git - friendica.git/commitdiff
Prevent fatal error when probing WebFinger address in Network\Probe::feed
authorHypolite Petovan <hypolite@mrpetovan.com>
Thu, 26 Jan 2023 05:00:55 +0000 (00:00 -0500)
committerHypolite Petovan <hypolite@mrpetovan.com>
Fri, 27 Jan 2023 06:24:22 +0000 (01:24 -0500)
src/Network/Probe.php

index d35490d0d366f7e4ab2b91c10b957e56649345b6..7c2760393a94b9aaa2b207603653c9d3557da8ec 100644 (file)
@@ -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);