Handle servers that return wrong webfinger payload (#415)

This commit is contained in:
Michael Manfre 2023-01-14 16:19:47 -05:00 committed by GitHub
parent f69c7304c1
commit 1f44e93518
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -683,6 +683,7 @@ class Identity(StatorModel):
"JSON parse error fetching webfinger", "JSON parse error fetching webfinger",
response.content, response.content,
) )
try:
if data["subject"].startswith("acct:"): if data["subject"].startswith("acct:"):
data["subject"] = data["subject"][5:] data["subject"] = data["subject"][5:]
for link in data["links"]: for link in data["links"]:
@ -691,6 +692,9 @@ class Identity(StatorModel):
and link.get("rel") == "self" and link.get("rel") == "self"
): ):
return link["href"], data["subject"] return link["href"], data["subject"]
except KeyError:
# Server returning wrong payload structure
pass
return None, None return None, None
async def fetch_actor(self) -> bool: async def fetch_actor(self) -> bool: