mirror of
https://akkoma.dev/AkkomaGang/akkoma.git
synced 2025-01-10 09:30:45 +00:00
don't allow a nil inbox to obliterate federation
This commit is contained in:
parent
2e049037de
commit
1ffbaa2924
|
@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
## 2025.01.01
|
||||||
|
|
||||||
|
Hotfix: Federation could break if a null value found its way into `should_federate?\1`
|
||||||
|
|
||||||
## 2025.01
|
## 2025.01
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
Config.get([:mrf_simple, :accept])
|
Config.get([:mrf_simple, :accept])
|
||||||
end
|
end
|
||||||
|
|
||||||
def should_federate?(url) do
|
def should_federate?(url) when is_binary(url) do
|
||||||
%{host: host} = URI.parse(url)
|
%{host: host} = URI.parse(url)
|
||||||
|
|
||||||
with {nil, false} <- {nil, is_nil(host)},
|
with {nil, false} <- {nil, is_nil(host)},
|
||||||
|
@ -137,6 +137,8 @@ defmodule Pleroma.Web.ActivityPub.Publisher do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def should_federate?(_), do: false
|
||||||
|
|
||||||
@spec recipients(User.t(), Activity.t()) :: list(User.t()) | []
|
@spec recipients(User.t(), Activity.t()) :: list(User.t()) | []
|
||||||
defp recipients(actor, activity) do
|
defp recipients(actor, activity) do
|
||||||
followers =
|
followers =
|
||||||
|
|
|
@ -519,6 +519,9 @@ defmodule Pleroma.Web.ActivityPub.PublisherTest do
|
||||||
test "should not obliterate itself if the inbox URL is bad" do
|
test "should not obliterate itself if the inbox URL is bad" do
|
||||||
url = "/inbox"
|
url = "/inbox"
|
||||||
refute Pleroma.Web.ActivityPub.Publisher.should_federate?(url)
|
refute Pleroma.Web.ActivityPub.Publisher.should_federate?(url)
|
||||||
|
|
||||||
|
url = nil
|
||||||
|
refute Pleroma.Web.ActivityPub.Publisher.should_federate?(url)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue