diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c743e5bd..d1e3a42c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ## Fixed - Meilisearch: order of results returned from our REST API now actually matches how Meilisearch ranks results +- AP objects with additional JSON-LD profiles beyond ActivityStreams can now be fetched ## Changed - Refactored Rich Media to cache the content in the database. Fetching operations that could block status rendering have been eliminated. diff --git a/lib/pleroma/object/fetcher.ex b/lib/pleroma/object/fetcher.ex index 937026e04..54ea9e74e 100644 --- a/lib/pleroma/object/fetcher.ex +++ b/lib/pleroma/object/fetcher.ex @@ -369,8 +369,12 @@ def get_object(id) do {"activity+json", _} -> {:ok, final_id, body} - {"ld+json", %{"profile" => "https://www.w3.org/ns/activitystreams"}} -> - {:ok, final_id, body} + {"ld+json", %{"profile" => profiles}} -> + if "https://www.w3.org/ns/activitystreams" in String.split(profiles) do + {:ok, final_id, body} + else + {:error, {:content_type, content_type}} + end _ -> {:error, {:content_type, content_type}} diff --git a/test/pleroma/object/fetcher_test.exs b/test/pleroma/object/fetcher_test.exs index 74f2cd31f..62dd64625 100644 --- a/test/pleroma/object/fetcher_test.exs +++ b/test/pleroma/object/fetcher_test.exs @@ -754,7 +754,7 @@ test "should return ok if the content type is application/activity+json" do assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2") end - test "should return ok if the content type is application/ld+json with a profile" do + test "should return ok if the content type is application/ld+json with the ActivityStream profile" do Tesla.Mock.mock(fn %{ method: :get, @@ -774,6 +774,26 @@ test "should return ok if the content type is application/ld+json with a profile assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2") end + test "should return ok if the content type is application/ld+json with several profiles" do + Tesla.Mock.mock(fn + %{ + method: :get, + url: "https://mastodon.social/2" + } -> + %Tesla.Env{ + status: 200, + url: "https://mastodon.social/2", + headers: [ + {"content-type", + "application/ld+json; profile=\"https://example.org/ns/superduperspec https://www.w3.org/ns/activitystreams\""} + ], + body: "{}" + } + end) + + assert {:ok, _, "{}"} = Fetcher.get_object("https://mastodon.social/2") + end + test "should not return ok with other content types" do Tesla.Mock.mock(fn %{