From b3014ebf06c79511c6f0e60344719b539e914181 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 29 Aug 2021 13:37:07 +0200 Subject: [PATCH 1/2] Catch TransferExceptions for HTTPClient::finalUrl() in case the headers are empty --- statusnet/statusnet.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index 6c7aec92..cd338543 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -58,6 +58,7 @@ use Friendica\Model\User; use Friendica\Protocol\Activity; use Friendica\Util\DateTimeFormat; use Friendica\Util\Strings; +use GuzzleHttp\Exception\TransferException; function statusnet_install() { @@ -1426,7 +1427,12 @@ function statusnet_convertmsg(App $a, $body) Logger::log("statusnet_convertmsg: expanding url " . $match[1], Logger::DEBUG); - $expanded_url = DI::httpClient()->finalUrl($match[1]); + try { + $expanded_url = DI::httpClient()->finalUrl($match[1]); + } catch (TransferException $exception) { + Logger::notice('statusnet_convertmsg: Couldn\'t get final URL.', ['url' => $match[2], 'exception' => $exception]); + $expanded_url = $match[2]; + } Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG); From c06fff692124c112856219fc323675c80891a82f Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 29 Aug 2021 14:26:05 +0200 Subject: [PATCH 2/2] Fixed wrong index .. --- statusnet/statusnet.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/statusnet/statusnet.php b/statusnet/statusnet.php index cd338543..c7c1d97b 100644 --- a/statusnet/statusnet.php +++ b/statusnet/statusnet.php @@ -1430,8 +1430,8 @@ function statusnet_convertmsg(App $a, $body) try { $expanded_url = DI::httpClient()->finalUrl($match[1]); } catch (TransferException $exception) { - Logger::notice('statusnet_convertmsg: Couldn\'t get final URL.', ['url' => $match[2], 'exception' => $exception]); - $expanded_url = $match[2]; + Logger::notice('statusnet_convertmsg: Couldn\'t get final URL.', ['url' => $match[1], 'exception' => $exception]); + $expanded_url = $match[1]; } Logger::log("statusnet_convertmsg: fetching data for " . $expanded_url, Logger::DEBUG);