diff options
author | uvok | 2025-01-19 19:13:15 +0100 |
---|---|---|
committer | uvok | 2025-01-19 19:13:15 +0100 |
commit | c717151c1c88722345af386f28e4ab1c559df424 (patch) | |
tree | f2230d4e697909d5c5f89ae585ee9a71ca569752 | |
parent | 9e525d3101d42d6fa0311efa822723e99161a72a (diff) |
Catch some malformed input
-rw-r--r-- | hello-fusepy.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/hello-fusepy.py b/hello-fusepy.py index 1fce36f..dc9117e 100644 --- a/hello-fusepy.py +++ b/hello-fusepy.py @@ -75,7 +75,9 @@ class ActivityPubStatusProvider(StatusProvider): s["object"]["published"], ) for s in status_items - if s["type"] == "Create" + if s.get("type", None) == "Create" + and "object" in s + and all(key in s["object"] for key in ["id", "content", "published"]) ] @@ -98,7 +100,7 @@ class MastodonStatusProvider(StatusProvider): return self._fallback_error(getattr(e, "message", str(e))) user = res.json() - self.userid = user.get("id") + self.userid = user.get("id", None) if not self.userid: return self._fallback_error("Malformed content in querying user ID.") @@ -121,6 +123,7 @@ class MastodonStatusProvider(StatusProvider): s["created_at"], ) for s in statuses + if all(key in s for key in ["id", "content", "created_at"]) ] @@ -143,7 +146,7 @@ class StatusFileSystem(Operations, LoggingMixIn): "st_uid": uid, "st_gid": gid, } - found = next((s for s in self.statuses if "/" + s.id == path), None) + found = next((s for s in self.statuses if s.id == path[1:]), None) if found: published_dt = dtp.fromisoformat(found.published) pubunix = published_dt.timestamp() @@ -176,7 +179,7 @@ class StatusFileSystem(Operations, LoggingMixIn): return self.fd def read(self, path, size, offset, fh): - found = next(s for s in self.statuses if "/" + s.id == path) + found = next(s for s in self.statuses if s.id == path[1:]) if found: return found.content.encode("utf8") raise FuseOSError(errno.ENOENT) |