]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/PortableContact.php
Merge pull request #7647 from annando/inter-transport
[friendica.git] / src / Protocol / PortableContact.php
index 7900ff540bfda7672d76416a6acba139c6b8d676..def8f1b628bc3b667636843c9d701f2bf331c5fb 100644 (file)
@@ -505,8 +505,15 @@ class PortableContact
                $last_updated = "";
 
                foreach ($entries as $entry) {
-                       $published = DateTimeFormat::utc($xpath->query('atom:published/text()', $entry)->item(0)->nodeValue);
-                       $updated   = DateTimeFormat::utc($xpath->query('atom:updated/text()'  , $entry)->item(0)->nodeValue);
+                       $published_item = $xpath->query('atom:published/text()', $entry)->item(0);
+                       $updated_item   = $xpath->query('atom:updated/text()'  , $entry)->item(0);
+                       $published      = isset($published_item->nodeValue) ? DateTimeFormat::utc($published_item->nodeValue) : null;
+                       $updated        = isset($updated_item->nodeValue) ? DateTimeFormat::utc($updated_item->nodeValue) : null;
+
+                       if (!isset($published) || !isset($updated)) {
+                               Logger::notice('Invalid entry for XPath.', ['entry' => $entry, 'profile' => $profile]);
+                               continue;
+                       }
 
                        if ($last_updated < $published) {
                                $last_updated = $published;
@@ -658,7 +665,7 @@ class PortableContact
                $nodeinfo2_url = '';
 
                foreach ($nodeinfo['links'] as $link) {
-                       if (!is_array($link) || empty($link['rel'])) {
+                       if (!is_array($link) || empty($link['rel']) || empty($link['href'])) {
                                Logger::log('Invalid nodeinfo format for ' . $server_url, Logger::DEBUG);
                                continue;
                        }
@@ -742,7 +749,7 @@ class PortableContact
                $friendica = false;
                $gnusocial = false;
 
-               if (is_array($nodeinfo['protocols']['inbound'])) {
+               if (!empty($nodeinfo['protocols']['inbound']) && is_array($nodeinfo['protocols']['inbound'])) {
                        foreach ($nodeinfo['protocols']['inbound'] as $inbound) {
                                if ($inbound == 'diaspora') {
                                        $diaspora = true;
@@ -997,7 +1004,7 @@ class PortableContact
                $server_url = str_replace("http://", "https://", $server_url);
 
                // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
-               $curlResult = Network::curl($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
+               $curlResult = Network::curl($server_url."/.well-known/host-meta", false, ['timeout' => 20]);
 
                // Quit if there is a timeout.
                // But we want to make sure to only quit if we are mostly sure that this server url fits.
@@ -1014,7 +1021,7 @@ class PortableContact
                        $server_url = str_replace("https://", "http://", $server_url);
 
                        // We set the timeout to 20 seconds since this operation should be done in no time if the server was vital
-                       $curlResult = Network::curl($server_url."/.well-known/host-meta", false, $redirects, ['timeout' => 20]);
+                       $curlResult = Network::curl($server_url."/.well-known/host-meta", false, ['timeout' => 20]);
 
                        // Quit if there is a timeout
                        if ($curlResult->isTimeout()) {
@@ -1617,7 +1624,7 @@ class PortableContact
                        if (!empty($accesstoken)) {
                                $api = 'https://instances.social/api/1.0/instances/list?count=0';
                                $header = ['Authorization: Bearer '.$accesstoken];
-                               $curlResult = Network::curl($api, false, $redirects, ['headers' => $header]);
+                               $curlResult = Network::curl($api, false, ['headers' => $header]);
 
                                if ($curlResult->isSuccess()) {
                                        $servers = json_decode($curlResult->getBody(), true);