]> git.mxchange.org Git - friendica.git/blobdiff - src/Protocol/PortableContact.php
Issue 5436: Don't store tags that are too long
[friendica.git] / src / Protocol / PortableContact.php
index 289eee90e9b26685d82f7022482c34fec9a24506..a94affd0470398e8f898ba66cb51147ca04a1eb4 100644 (file)
@@ -659,6 +659,10 @@ class PortableContact
                $nodeinfo2_url = '';
 
                foreach ($nodeinfo['links'] as $link) {
+                       if (!is_array($link) || empty($link['rel'])) {
+                               logger('Invalid nodeinfo format for ' . $server_url, LOGGER_DEBUG);
+                               continue;
+                       }
                        if ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/1.0') {
                                $nodeinfo1_url = $link['href'];
                        } elseif ($link['rel'] == 'http://nodeinfo.diaspora.software/ns/schema/2.0') {
@@ -1467,7 +1471,9 @@ class PortableContact
                        $tags = [];
                        foreach ($data['tags'] as $tag) {
                                $tag = mb_strtolower($tag);
-                               $tags[$tag] = $tag;
+                               if (count($tag) < 100) {
+                                       $tags[$tag] = $tag;
+                               }
                        }
 
                        foreach ($tags as $tag) {
@@ -1638,10 +1644,12 @@ class PortableContact
 
                $retdata = Network::curl($url);
 
-               if ($retdata["success"]) {
+               if ($retdata["success"] && !empty($retdata["body"])) {
                        $data = json_decode($retdata["body"], true);
 
-                       self::discoverServer($data, 2);
+                       if (!empty($data)) {
+                               self::discoverServer($data, 2);
+                       }
 
                        if (Config::get('system', 'poco_discovery') > 1) {
                                $timeframe = Config::get('system', 'poco_discovery_since');
@@ -1659,9 +1667,13 @@ class PortableContact
 
                                $retdata = Network::curl($url);
 
-                               if ($retdata["success"]) {
+                               if ($retdata["success"] && !empty($retdata["body"])) {
                                        logger("Fetch all global contacts from the server " . $server["nurl"], LOGGER_DEBUG);
-                                       $success = self::discoverServer(json_decode($retdata["body"], true));
+                                       $data = json_decode($retdata["body"], true);
+
+                                       if (!empty($data)) {
+                                               $success = self::discoverServer($data);
+                                       }
                                }
 
                                if (!$success && (Config::get('system', 'poco_discovery') > 2)) {
@@ -1756,7 +1768,11 @@ class PortableContact
                                $retdata = Network::curl($url);
 
                                if (!empty($retdata['success'])) {
-                                       self::discoverServer(json_decode($retdata['body'], true), 3);
+                                       $data = json_decode($retdata["body"], true);
+
+                                       if (!empty($data)) {
+                                               self::discoverServer($data, 3);
+                                       }
                                }
                        }
                }