From 1b20d3704f96002db8b3aa47d2556bda121f7891 Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Mon, 21 Oct 2024 12:23:39 -0400 Subject: [PATCH] Catch errors around Like/Unlike actions Previously, we'd get nil panics or insert blank post IDs Ref T906 --- activitypub.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/activitypub.go b/activitypub.go index 6b3b8ee..33ec2fe 100644 --- a/activitypub.go +++ b/activitypub.go @@ -392,7 +392,13 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request }, 0) */ + if obj == nil { + return fmt.Errorf("didn't get ObjectIRI to Like") + } likePostID, err = parsePostIDFromURL(app, obj) + if err != nil { + return err + } // Finally, get actor information _, from := l.GetActor(0) @@ -458,7 +464,13 @@ func handleFetchCollectionInbox(app *App, w http.ResponseWriter, r *http.Request _, from := like.GetActor(0) obj := like.Raw().GetObjectIRI(0) + if obj == nil { + return fmt.Errorf("didn't get ObjectIRI for Undo Like") + } unlikePostID, err = parsePostIDFromURL(app, obj) + if err != nil { + return err + } fullActor, remoteUser, err = getActor(app, from.String()) if err != nil { return err