From bfb15f2b33d0127c8bf3fde0109acb44a7669da4 Mon Sep 17 00:00:00 2001 From: Michael Date: Tue, 19 Dec 2017 09:57:24 +0000 Subject: [PATCH] Workaround for servers that react strange --- src/Protocol/PortableContact.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 631d4b7a32..e5573d1cee 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -658,6 +658,11 @@ class PortableContact return false; } + // When the nodeinfo url isn't on the same host, then there is obviously something wrong + if (parse_url($server_url, PHP_URL_HOST) != parse_url($nodeinfo_url, PHP_URL_HOST)) { + return false; + } + $serverret = z_fetch_url($nodeinfo_url); if (!$serverret["success"]) { return false; @@ -932,6 +937,13 @@ class PortableContact $site_name = ''; } } + // There are servers out there who don't return 404 on a failure + // We have to be sure that don't misunderstand this + if (is_null($data)) { + $poco = ""; + $noscrape = ""; + $network = ""; + } } } @@ -1002,6 +1014,7 @@ class PortableContact $serverret = z_fetch_url($server_url."/api/v1/instance"); if ($serverret["success"] && ($serverret["body"] != '')) { $data = json_decode($serverret["body"]); + if (isset($data->version)) { $platform = "Mastodon"; $version = $data->version; @@ -1107,6 +1120,7 @@ class PortableContact $serverret = z_fetch_url($server_url."/statistics.json"); if ($serverret["success"]) { $data = json_decode($serverret["body"]); + if (isset($data->version)) { $version = $data->version; // Version numbers on statistics.json are presented with additional info, e.g.: -- 2.39.5