1
0
Fork 0

Prevent fatal error when probing WebFinger address in Network\Probe::feed

This commit is contained in:
Hypolite Petovan 2023-01-26 00:00:55 -05:00
parent 6bedd190b9
commit 91d8cd2c87

View 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);