diff --git a/activitypub.py b/activitypub.py index b814610b..4e5f6c24 100644 --- a/activitypub.py +++ b/activitypub.py @@ -704,7 +704,7 @@ def postprocess_as2_actor(actor, user=None): assert isinstance(actor, dict) url = user.web_url() - urls = util.get_list(actor, 'url') + urls = [u for u in util.get_list(actor, 'url') if u and not u.startswith('acct:')] if not urls and url: urls = [url] if urls: diff --git a/tests/test_activitypub.py b/tests/test_activitypub.py index 8169e202..1f132856 100644 --- a/tests/test_activitypub.py +++ b/tests/test_activitypub.py @@ -1852,6 +1852,13 @@ class ActivityPubUtilsTest(TestCase): 'value': 'two', }], got['attachment']) + def test_postprocess_as2_actor_strips_acct_url(self): + self.assert_equals('http://localhost/r/http://user.com/', + postprocess_as2_actor(as2.from_as1({ + 'objectType': 'person', + 'urls': ['http://user.com/', 'acct:foo@bar'], + }), user=self.user)['url']) + def test_postprocess_as2_actor_preserves_preferredUsername(self): # preferredUsername stays y.z despite user's username. since Mastodon # queries Webfinger for preferredUsername@fed.brid.gy