From 2ebebe9abc7a92266de0a4ba817af531cd50c551 Mon Sep 17 00:00:00 2001 From: RealKinetix Date: Wed, 14 Jul 2021 10:15:19 -0700 Subject: [PATCH] Sanitize negative followers count on APContact 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Model/APContact.php b/src/Model/APContact.php index aa5dbe2f71..971a48d9dd 100644 --- a/src/Model/APContact.php +++ b/src/Model/APContact.php @@ -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']; } -- 2.39.5