]> git.mxchange.org Git - friendica.git/commitdiff
Sanitize negative followers count on APContact
authorRealKinetix <kinetix@isurf.ca>
Wed, 14 Jul 2021 17:15:19 +0000 (10:15 -0700)
committerRealKinetix <kinetix@isurf.ca>
Wed, 14 Jul 2021 17:15:19 +0000 (10:15 -0700)
Please see
https://github.com/friendica/friendica/issues/9498#issuecomment-818894106
and related discussion regarding this - it appears it's possible for AP
users, maybe just Mastodon users, to have a negative followers count.
This causes fatal errors in Friendica, so I think we should sanitize
this input.

src/Model/APContact.php

index aa5dbe2f7188e8bbe898e65e62f043b8a12eacf8..971a48d9dd00a46753c18d8e4c12054103751f68 100644 (file)
@@ -272,6 +272,11 @@ class APContact
 
                if (!empty($apcontact['followers'])) {
                        $followers = ActivityPub::fetchContent($apcontact['followers']);
+                       // Mastodon seriously allows for this condition? 
+                       // Jul 14 2021 - See https://mastodon.online/@goes11 for a negative followers count
+                       if ($followers['totalItems'] < 0) {
+                         $followers['totalItems'] = 0;
+                       }
                        if (!empty($followers['totalItems'])) {
                                $apcontact['followers_count'] = $followers['totalItems'];
                        }