MRF: add policy for normalizing HTML markup (local and remote) to a specific policy
This commit is contained in:
parent
95376ac1fe
commit
342ed84446
2 changed files with 27 additions and 0 deletions
|
@ -104,6 +104,8 @@
|
|||
|
||||
config :pleroma, :user, deny_follow_blocked: true
|
||||
|
||||
config :pleroma, :mrf_normalize_markup, scrub_policy: Pleroma.HTML.Scrubber.Default
|
||||
|
||||
config :pleroma, :mrf_rejectnonpublic,
|
||||
allow_followersonly: false,
|
||||
allow_direct: false
|
||||
|
|
25
lib/pleroma/web/activity_pub/mrf/normalize_markup.ex
Normal file
25
lib/pleroma/web/activity_pub/mrf/normalize_markup.ex
Normal file
|
@ -0,0 +1,25 @@
|
|||
defmodule Pleroma.Web.ActivityPub.MRF.NormalizeMarkup do
|
||||
alias Pleroma.HTML
|
||||
|
||||
@behaviour Pleroma.Web.ActivityPub.MRF
|
||||
|
||||
@mrf_normalize_markup Application.get_env(:pleroma, :mrf_normalize_markup)
|
||||
|
||||
def filter(%{"type" => activity_type} = object) when activity_type == "Create" do
|
||||
scrub_policy = Keyword.get(@mrf_normalize_markup, :scrub_policy)
|
||||
|
||||
child = object["object"]
|
||||
|
||||
content =
|
||||
child["content"]
|
||||
|> HTML.filter_tags(scrub_policy)
|
||||
|
||||
child = Map.put(child, "content", content)
|
||||
|
||||
object = Map.put(object, "object", child)
|
||||
|
||||
{:ok, object}
|
||||
end
|
||||
|
||||
def filter(object), do: {:ok, object}
|
||||
end
|
Loading…
Reference in a new issue